Patch: Fix KEncodingProber crashiness
kde at randomguy3.me.uk
Fri Mar 20 20:08:41 GMT 2009
On Friday 20 March 2009 19:38:43 Jeff Mitchell wrote:
> Christoph Feck wrote:
> > Am Friday 20 March 2009 19:25:57 schrieb Jeff Mitchell:
> > 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?
Return it to a strdup. The QByteArray is of no use whatsoever here that I can
see, and even if it does do a deep copy, all you're doing is hiding the
Besides which, if d->prober exists, you're doing a strdup anyway, so you
should be doing the same if d->prober is null.
Why have I got six monitors? Because I haven't got room for eight.
-- Terry Pratchett
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 197 bytes
Desc: This is a digitally signed message part.
More information about the kde-core-devel