GNOME Bugzilla – Bug 784049
g_free() and xmlFree() are not equivalent
Last modified: 2017-06-22 07:42:30 UTC
And there's tons of code in libgepub that seems to think it is. Either: xmlChar *foo = xmlGetProp (node, (const xmlChar *) "foo"); priv->foo = g_strdup ((char *) foo); xmlFree (foo); Or make "priv->foo" an xmlChar and use the proper destructor. (GepubResource is broken in this regard, any reason why the struct is public?)
GepubResource is public because there's one method that returns the GHashTable of resources, gepub_doc_get_resources, so if you want to get the mime or the uri you need to know the structure. To make it private we should add the getters for uri and mime. And about the xmlFree... yes, there's a lot of xmlGetProp that doesn't free the string correctly.
Created attachment 354215 [details] [review] Transforming xmlChar* to gchar* and freeing correctly
Attachment 354215 [details] pushed as 6c92f66 - Transforming xmlChar* to gchar* and freeing correctly