cstring returning invalid encoding? mp3's
mpyne at purinchu.net
Wed Sep 23 02:46:29 CEST 2009
On Tuesday 22 September 2009 07:18:07 rengels wrote:
> On Tuesday 22 September 2009 01:55:49 am ext Caleb Cushing wrote:
> > figured it out 20-ish minutes ago... memory corruption. apparently the
> > memory was popping off the stack before the pointer was assigned (or
> > something like that). using an intermediate variable.
> > TagLib::String s( tfile.tag()->title() );
> > const char *ttitle = s.toCString(true);
> > has solved this issue.
> Hi Caleb,
> it should not do that.
> As tfile does not run out of scope tag and tag->title should also remain
> valid. Strange...
tfile was not the issue, it was a temporary String returned by tfile.tag()-
Look at the API docs:
"This string remains valid until the String instance is destroyed or another
export method is called."
With tfile.tag()->title().toCString(true);, the temporary String returned by
title() is destroyed essentially as soon as that semicolon is encountered,
leaving the memory pointed to by ttitle in an undefined state. Forcing the
String to stay alive by storing it in a local variable also keeps the ttitle
- Michael Pyne
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/taglib-devel/attachments/20090922/94572c40/attachment.sig
More information about the taglib-devel