KEncodingProber likes to crash. I'm guessing no one is really using this
code outside of us (and we just started), but it has some glaring issues:
1) Memory is allocated to a const char * by using strdup, but is removed by
using delete, not free.
2) Memory is always allocated on the heap to the const char * in the
constructor, but this memory is not freed before overwriting it with a new
value, leading to a (miniscule) memory leak.
3) Largest problem: in the function unicodeTest, there are assignments from
string literals, but later in the destructor there is a delete call (which
is what is sparking the crash). When the string literal is being assigned,
the string itself isn't being copied, but rather the address of the string
literal is being copied. The literal itself exists in the executable, not
on the heap, so trying to delete it is likely to cause bad things to happen
(and is probably the source of the crashes we are seeing).
This patch does the following:
*Replaces the const char * pointer with a QString on the stack for safety.
*Replaces a strdup call with a QByteArray and a .data() call, which is not
strictly necessary but ensures that any safety checks in QByteArray are
I'd like to put it in trunk and backport it for 4.2.2.
Description: Text Data