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/
[email protected] | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml