You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by "RUOFF, LARS (LARS)" <la...@alcatel-lucent.com> on 2014/11/21 14:40:44 UTC

log4cxx 0.9.7: Fix for memory leak in gnomexml.cpp when parsing configuration file (Linux)

Hi,
FYI, another memory leak we found in log4cxx 0.9.7 (this is an old version!):
During parsing, allocated XML attributes are not freed again.
Detected with valgrind/memcheck analysis.

Here's a fix:
(Base is 0.9.7)
\src\gnomexml.cpp:

@@ -126,6 +126,7 @@
                                   if (attributeValue != 0
                                               && elementId == A2T(attributeValue))
                                   {
+                                              xmlFree(attributeValue);
                                               return new GnomeXMLDOMElement(node);
                                   }
                       }
@@ -178,7 +179,18 @@
           USES_CONVERSION;
           char * attributeValue = (char *)xmlGetProp(
                       element, (const xmlChar *)T2A(name.c_str()));
-           return (attributeValue == 0) ? String() : A2T(attributeValue);
+          String ret;
+          if (attributeValue == 0)
+          {
+                      ret=String();
+          }
+          else
+          {
+                      ret=A2T(attributeValue);
+                      xmlFree(attributeValue);
+          }
+          return ret;
+          //return (attributeValue == 0) ? String() : A2T(attributeValue);
}
 // GnomeXMLDOMNodeList


Best regards,
Lars Ruoff


Re: log4cxx 0.9.7: Fix for memory leak in gnomexml.cpp when parsing configuration file (Linux)

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Rhys Ulerich,
am Freitag, 12. Dezember 2014 um 04:41 schrieben Sie:

> Anyone recognize what we should review in trunk to see if we've got
> the same issue currently?

I would have guessed DOMConfigurator, but that works completely
different and gnomexml.cpp might have been some distribution specific
patch or something completely unrelated to the original codebase as
well. Don't bother anymore, if there's still a problem someone will
surely report it...

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


Re: log4cxx 0.9.7: Fix for memory leak in gnomexml.cpp when parsing configuration file (Linux)

Posted by Rhys Ulerich <rh...@gmail.com>.
> FYI, another memory leak we found in log4cxx 0.9.7 (this is an old
> version!)

Thank you Lars.  It doesn't seem like that code still exists in trunk.
We've no file by that name, and tokens like xmlFree and xmlGetProp do
not appear in the current codebase.

Anyone recognize what we should review in trunk to see if we've got
the same issue currently?

- Rhys