Re: [xml] xmlFreeDoc() on iOS 4 - crashes

On Thu, Oct 14, 2010 at 09:28:20AM +0200, Csaba Raduly wrote:

On Wed, Oct 13, 2010 at 9:54 PM, Chi Yin Luk  wrote:

xmlDocPtr doc;
doc = xmlNewDoc((cost xmlChar*)XML_DEFAULT_VERSION);
doc->encoding =âutf-8â;

xmlFreeDoc does a xmlFree on doc->encoding, but you set it to a string
which was not dynamically allocated. In effect, you are calling
xmlFree on the "utf-8" string literal. This is wrong. You need to do
at least this:

doc->encoding = xmlStrDup("utf-8");

  and xmlFree(doc->encoding) if it was not NULL before the affectation !


Daniel Veillard      | libxml Gnome XML XSLT toolkit
daniel veillard com  | Rpmfind RPM search engine | virtualization library

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]