bugCERTI - Bugs: bug #19576, XmlParser's memory leak bug

 
 

bug #19576: XmlParser's memory leak bug

Submitted by:  moosefly <moosefly>
Submitted on:  Wed 11 Apr 2007 09:35:24 AM UTC  
 
Category: CERTISeverity: 3 - Normal
Item Group: Software errorStatus: Ready For Test
Privacy: PublicAssigned to: Eric NOULARD <erk>
Open/Closed: ClosedRelease: 3.2.1
Reproducibility: Every TimeFixed Release: 3.2.5

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 31 Aug 2007 12:48:38 PM UTC, comment #3:

I've just checked-in the fix in the CVS tree.

Eric NOULARD <erk>
Project AdministratorIn charge of this item.
Mon 07 May 2007 01:29:18 PM UTC, comment #2:

hi,Eric

>There is a bunch of call to xmlGetProp in either
>libCERTI/XmlParser.cc orRTIG/Federation.cc


>Would you suggest to replace all those calls with
>proper xmlGetProp / xmlFree pairing
>or do you think the only trouble may come
>from the example you have given?


yes,every xmlGetProp must be followed with xmlFree.

>Moreover, I did valgrind the billard application using
>valgrind --leak-check=full billard -n1 -fTest -FTest.xml -t 10
>and did not catch possible leaks (in the xmlParser region).


I have never used valgrind, so I can't give any commention about it.

I found this memory leak bug because I have made some benchmark about the "xml vs fed" parsing speed. My test code parsed the xml file 5000 times and the memory allocated by the program continually increased. After I fixed it by xmlFree, the memory allocated by the program became constant.

>Would you have time to propose us with
>a patch against current CVS?


As you seen, I haven't make full exam about the certi's code, and I think it's very convenient to fix it: just search all the "xmlGetProp" and add the "xmlFree" after the property has been worked.

moosefly <moosefly>
Fri 04 May 2007 01:08:59 PM UTC, comment #1:

There is a bunch of call to xmlGetProp in
either
libCERTI/XmlParser.cc
or
RTIG/Federation.cc

Would you suggest to replace all those calls with
proper xmlGetProp / xmlFree pairing
or do you think the only trouble may come
from the example you have given?

Moreover, I did valgrind the billard application using
valgrind --leak-check=full billard -n1 -fTest -FTest.xml -t 10
and did not catch possible leaks (in the xmlParser region).

Nevertheless you seem to be right, we must pair
xmlGetProp and xmlFree properly:
http://mail.gnome.org/archives/xml/2005-December/msg00125.html

Would you have time to propose us with
a patch against current CVS?

(you may join a patch file to the bug tracker).

Eric NOULARD <erk>
Project AdministratorIn charge of this item.
Wed 11 Apr 2007 09:35:24 AM UTC, original submission:

There is potential memory leak bug in the libxml2's API: xmlGetProp().

"xmlGetProp returns a string that must be freed with the xmlFree() function when you are done with it, or else your program will have a memory leak."

——http://student.santarosa.edu/~dturover/?node=libxml2

Unfortunately, this memory leak found in the CERTI's XmlParser.

After I modified the code just like :

---current->setName((char *) xmlGetProp(cur, ATTRIBUTE_NAME));

+++char tmp =(char *) xmlGetProp(cur, ATTRIBUTE_NAME);
+++current->setName(tmp);
+++xmlFree(tmp);

everything is OK.

Cheers

moosefly

moosefly <moosefly>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by erk (Posted a comment)
  • -unavailable- added by moosefly (Submitted the item)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 19 Nov 2007 02:28:59 PM UTCerkOpen/ClosedOpen=>Closed
      Fixed ReleaseNextRelease=>3.2.5
    Mon 03 Sep 2007 08:55:18 AM UTCerkAssigned toNone=>erk
    Fri 31 Aug 2007 12:48:38 PM UTCerkStatusNone=>Ready For Test
      Fixed ReleaseUnknown=>NextRelease
    Fri 04 May 2007 01:08:59 PM UTCerkReleaseNone=>3.2.1
      Fixed ReleaseNone=>Unknown

    Back to the top


    Powered by Savane 3.1-cleanup1