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



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

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(doc);

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

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/



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