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 702320 - Resource Leak in xmllint.c
Resource Leak in xmllint.c
Product: libxml2
Classification: Platform
Component: general
git master
Other Linux
: Normal critical
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Reported: 2013-06-15 07:37 UTC by Gaurav
Modified: 2013-07-12 04:41 UTC
See Also:
GNOME target: ---
GNOME version: ---

Description Gaurav 2013-06-15 07:37:56 UTC
In Function streamFile

Following code block:

if (memory) {
     ------------Some Code ----------------
        if ((fd = open(filename, O_RDONLY)) < 0)
	base = mmap(NULL, info.st_size, PROT_READ, MAP_SHARED, fd, 0) ;
	if (base == (void *) MAP_FAILED)

	-------Some Code ---------------

 if (base == (void *) MAP_FAILED) is true, it returns. But does not close the fd.
  A tool reports: "Handle variable "fd" going out of scope leaks the handle. "

 So, It should be like: 
         if (base == (void *) MAP_FAILED){
Comment 1 Gaurav 2013-06-15 07:58:46 UTC
In the same file (xmllint.c) in function "parseAndPrintFile"
There is similar type of bug at line number: 2226 (

Patch for this is similar to above:

         if (base == (void *) MAP_FAILED){
Comment 2 Daniel Veillard 2013-07-12 04:41:18 UTC

the leak is not really important as this is part of a standalone
program and not within the library code. I fixed 3 areas where the
problem could occur, and made sure errors were properly reported
both as message and program exit value,

 thanks !