Christoph Feck wrote:
> Am Friday 20 March 2009 19:25:57 schrieb Jeff Mitchell:
>> *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.
> Who the heck designed this API?
I'm guessing whoever is holding the copyright in the header file :-)
> This here does not work, you are returning the address of a temporary,
> and the case when d->proper is non zero still uses strdup.
> @@ -204,7 +203,7 @@
> const char* KEncodingProber::encodingName() const
> if (!d->prober)
> - return strdup("UTF-8");
> + return QByteArray("UTF-8").data();
> return strdup(d->prober->GetCharSetName());
Does the .data() call on a QByteArray return a temporary? I thought it
returned a deep copy that was safe for e.g. passing outside of a function.
So, if QByteArray::data is returning the address of a temporary, do you
have a recommended Right Way(TM) fix? Or should I simply return that
part to strdup?