After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 784049 - g_free() and xmlFree() are not equivalent
g_free() and xmlFree() are not equivalent
Status: RESOLVED FIXED
Product: libgepub
Classification: Other
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: libgepub Maintainer(s)
libgepub Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2017-06-21 16:54 UTC by Bastien Nocera
Modified: 2017-06-22 07:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Transforming xmlChar* to gchar* and freeing correctly (4.25 KB, patch)
2017-06-22 07:41 UTC, Daniel Garcia
committed Details | Review

Description Bastien Nocera 2017-06-21 16:54:08 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?)
Comment 1 Daniel Garcia 2017-06-21 17:09:48 UTC
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.
Comment 2 Daniel Garcia 2017-06-22 07:41:33 UTC
Created attachment 354215 [details] [review]
Transforming xmlChar* to gchar* and freeing correctly
Comment 3 Daniel Garcia 2017-06-22 07:42:26 UTC
Attachment 354215 [details] pushed as 6c92f66 - Transforming xmlChar* to gchar* and freeing correctly