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 729849 - Avoid Possible null pointer dereference in xmlmemory.c
Avoid Possible null pointer dereference in xmlmemory.c
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2014-05-09 05:06 UTC by Gaurav
Modified: 2014-05-09 09:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Avoid Possible null pointer dereference in xmlmemory.c (552 bytes, patch)
2014-05-09 05:06 UTC, Gaurav
none Details | Review

Description Gaurav 2014-05-09 05:06:00 UTC
Created attachment 276209 [details] [review]
Avoid Possible null pointer dereference in xmlmemory.c

In file:
https://git.gnome.org/browse/libxml2/tree/xmlmemory.c

static void
xmlMemContentShow(FILE *fp, MEMHDR *p)
{
    int i,j,k,len = p->mh_size;
    const char *buf = (const char *) HDR_2_CLIENT(p);

    if (p == NULL) {
	fprintf(fp, " NULL");
	return;
    }



Here "p" is dereferenced before NULL check.
Hence if p is NULL, it may crash before NULL check.

Please apply attached patch.

Thanks.
Comment 1 Daniel Veillard 2014-05-09 09:02:08 UTC
Ah right, but it's a normal bug, the option of building the memory list and
being able to dump part of the content is only activated on build with
memory debug, it cannot be used in production as xmlFree and xmlMalloc are
then incompatible with free and malloc C library routines.

Fixed as commit 7966a761b77d24a70e8b81057c48319e32fbcc29

  thanks !

Daniel