Re: [xml] xmlFreeDoc() on iOS 4 - crashes
- From: Csaba Raduly <rcsaba gmail com>
- To: Chi Yin Luk <ChiYinL warshawgroup com>
- Cc: xml gnome org
- Subject: Re: [xml] xmlFreeDoc() on iOS 4 - crashes
- Date: Thu, 14 Oct 2010 09:28:20 +0200
On Wed, Oct 13, 2010 at 9:54 PM, Chi Yin Luk wrote:
I am using libxml184.108.40.206.dylib on my iPhone application.
The application is targeting iOS 3.2, but the xmlFreeDoc() fails when the
application is running on iPhone 4, but not on iOS 3.2 or before.
I also tried targeting iOS 4 and running on iPhone 4, same problem exist.
The problem is if I assign the encocoding of xmlDocPtr , then call
xmlFreeDoc to free the xmlDocPtr, it crashes with message:
“pointer being freed was not allocated”
The snippet of code as follow:
doc = xmlNewDoc((cost xmlChar*)XML_DEFAULT_VERSION);
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");
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ L w++$ tv+ b++ DI D++ 5++
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds
] [Thread Prev