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 708681 - null pointer check missing
null pointer check missing
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
git master
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2013-09-24 13:19 UTC by Phil Shafer
Modified: 2013-11-29 15:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fixes missing NULL checks (553 bytes, patch)
2013-09-30 05:16 UTC, Gaurav
none Details | Review

Description Phil Shafer 2013-09-24 13:19:46 UTC
In tree.c:xmlStaticCopyNodeList, the call to xmlStaticCopyNode is not checked for a NULL return value.

#endif /* LIBXML_TREE_ENABLED */
            q = xmlStaticCopyNode(node, doc, parent, 1);
        if (ret == NULL) {
            q->prev = NULL;
            ret = p = q;

If we run out of memory, we get a core dump.  Fix is:

--- branches/DEV_RPD_12Q3_BRANCH/dist/libxml2/tree.c	2011/12/27 09:06:00	487850
+++ branches/DEV_RPD_12Q3_BRANCH/dist/libxml2/tree.c	2011/12/27 09:12:34	487851
@@ -4267,6 +4267,8 @@
 	} else
 #endif /* LIBXML_TREE_ENABLED */
 	    q = xmlStaticCopyNode(node, doc, parent, 1);
+	if (q == NULL)
+	    return(NULL);
 	if (ret == NULL) {
 	    q->prev = NULL;
 	    ret = p = q;
Comment 1 Gaurav 2013-09-30 05:15:34 UTC
This seems bug, because "xmlStaticCopyNode" can return NULL.
Also, at line: 4301, xmlCopyDtd can return NULL.

Attached patch fixes both these scenarios.

Gaurav
Comment 2 Gaurav 2013-09-30 05:16:15 UTC
Created attachment 256051 [details] [review]
Fixes missing NULL checks
Comment 3 Daniel Veillard 2013-11-29 15:30:55 UTC
okay i applied the later patch but after changing the style to Phil's one
to match libxml2 code:

https://git.gnome.org/browse/libxml2/commit/?id=98a4e7128bc92559f05c754d0291a0a5906405d1

  thanks to both !

Daniel