Re: [xml] xmlFreeDoc() on iOS 4 - crashes
- From: "Chi Yin Luk" <ChiYinL warshawgroup com>
- To: "Csaba Raduly" <rcsaba gmail com>
- Cc: xml gnome org
- Subject: Re: [xml] xmlFreeDoc() on iOS 4 - crashes
- Date: Thu, 14 Oct 2010 12:08:57 -0400
Thanks X 1000 man!
It worked by doing xmlStrDup()! But I am just wondering why it would not
crash when running on iOS 3.2 or older.
Chi Yin Luk
540 Broadway, 4th floor
New York, NY 10012
phone: 212.966.4056, x. 201
email: chiyinl warshawgroup com
From: Csaba Raduly [mailto:rcsaba gmail com]
Sent: Thursday, October 14, 2010 3:28 AM
To: Chi Yin Luk
Cc: xml gnome org
Subject: Re: [xml] xmlFreeDoc() on iOS 4 - crashes
On Wed, Oct 13, 2010 at 9:54 PM, Chi Yin Luk wrote:
I am using libxml188.8.131.52.dylib on my iPhone application.
The application is targeting iOS 3.2, but the xmlFreeDoc() fails when
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
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
"People disagree with me. I just ignore them." -- Linus Torvalds
] [Thread Prev