2 issues:
(1) While compiling applications that use log4cxx library, I get bunch of warnings when I specify -Wall warning option to g++ (g++-3.3.X, maybe also older ones...) - something related to usage of virtual functions in classes that do not have virtual destructors (sorry, I don't have original warning listing...).
(2) When using valgrind (memory debugger, version 2.2.0, but older versions complain as well), I get errors regarding mismatched delete/delete[] on memory.
Reproducible: Always
Steps to Reproduce:
1. prepare some testing file that uses log4cxx, include log4cxx/logger.h
2. compile with -Wall flags
3. run using valgrind and check error output
Actual Results:
Basically nothing, just got bunch of warnings which can cause I miss other, more
important warnings. And there is a memory leak when deleting with simple delete
(and not delete[]) - it's not fatal since it's at the aplication exit, so
nothing fatal, actually.
Expected Results:
no warnings from g++, no memory leak reports from valgrind.
All the problems described above can be solved by this patch, it's a patch
against original log4cxx-0.9.7 as you get by untgzing original distribution tarball:
diff -ur log4cxx-0.9.7/include/log4cxx/helpers/class.h
log4cxx-0.9.7-adjusted/include/log4cxx/helpers/class.h
--- log4cxx-0.9.7/include/log4cxx/helpers/class.h 2004-05-10 14:41:02.000000000
+0200
+++ log4cxx-0.9.7-adjusted/include/log4cxx/helpers/class.h 2004-09-10
16:41:28.000000000 +0200
@@ -53,6 +53,7 @@
{
public:
Class(const String& name);
+ virtual ~Class() {};
virtual ObjectPtr newInstance() const;
const String& toString() const;
const String& getName() const;
diff -ur log4cxx-0.9.7/src/stringtokenizer.cpp
log4cxx-0.9.7-adjusted/src/stringtokenizer.cpp
--- log4cxx-0.9.7/src/stringtokenizer.cpp 2004-05-10 14:38:08.000000000 +0200
+++ log4cxx-0.9.7-adjusted/src/stringtokenizer.cpp 2004-09-17 19:58:37.000000000
+0200
@@ -39,7 +39,7 @@
StringTokenizer::~StringTokenizer()
{
- delete this->str;
+ delete[] this->str;
}
bool StringTokenizer::hasMoreTokens() const
Juraj, apologies are due. I thought I had commented on this bug when it first
came in but was mistaken.
negge@vt.edu
> I am seeing this problem currently. Any idea when this patch will be applied to the ebuild?
Sure, how about now :) I would have done this a lot sooner had I not forgotten
about it.
-r2 is in cvs.