[log4c] Patch to fix library reinitialization (bug #1095366).

František Dvořák valtri at fedoraproject.org
Thu May 8 19:20:19 UTC 2014


commit 639d91555b8f5afc138c3d8e1f05d9a0eec2e7ec
Author: František Dvořák <valtri at civ.zcu.cz>
Date:   Thu May 8 21:23:29 2014 +0200

    Patch to fix library reinitialization (bug #1095366).

 log4c.spec   |   12 +++++-
 reinit.patch |  111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 121 insertions(+), 2 deletions(-)
---
diff --git a/log4c.spec b/log4c.spec
index 5b1f0db..004c628 100644
--- a/log4c.spec
+++ b/log4c.spec
@@ -2,12 +2,16 @@
 
 Name:		log4c
 Version:	1.2.4
-Release:	1%{?dist}
+Release:	2%{?dist}
 Summary:	Library for logging application messages
 
 License:	LGPLv2+
 URL:		http://log4c.sourceforge.net/
 Source0:	http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
+# Double free or corruption with multiple log4c_init()/log4c_fini()
+# https://bugzilla.redhat.com/show_bug.cgi?id=1095366
+# Applied in upstream
+Patch0:         reinit.patch
 
 BuildRequires:	doxygen-latex
 BuildRequires:	expat-devel
@@ -48,10 +52,11 @@ This package contains %{name} documentation.
 
 %prep
 %setup -q
+%patch0 -p1
 
 
 %build
-%configure --enable-doc --disable-static
+%configure --enable-doc --enable-test --disable-static
 make %{?_smp_mflags}
 
 
@@ -99,6 +104,9 @@ sed -r -i \
 
 
 %changelog
+* Thu May 08 2014 František Dvořák <valtri at civ.zcu.cz> - 1.2.4-2
+- Patch to fix library reinitialization (bug #1095366)
+
 * Thu Oct 03 2013 František Dvořák <valtri at civ.zcu.cz> - 1.2.4-1
 - Release log4c 1.2.4
 - Add -doc subpackage
diff --git a/reinit.patch b/reinit.patch
new file mode 100644
index 0000000..c2a2d89
--- /dev/null
+++ b/reinit.patch
@@ -0,0 +1,111 @@
+From: František Dvořák <valtri at civ.zcu.cz>
+Date: Thu, 8 May 2014 12:09:34 +0000 (+0200)
+Subject: Better work with local static variables, fixes double free on re-initialiazation.
+X-Git-Url: http://scientific.zcu.cz/git/?p=log4c.git;a=commitdiff_plain;h=113e1dd0cef9e411ff52d75363bfe6f44be25987
+
+Better work with local static variables, fixes double free on re-initialiazation.
+---
+
+diff --git a/src/log4c/appender.c b/src/log4c/appender.c
+index aa939b2..e49f85b 100644
+--- a/src/log4c/appender.c
++++ b/src/log4c/appender.c
+@@ -31,22 +31,21 @@ struct __log4c_appender
+ };
+ 
+ sd_factory_t* log4c_appender_factory = NULL;
++static sd_hash_t* appender_types = NULL;
+ 
+ /*******************************************************************************/
+ static sd_hash_t* log4c_appender_types(void)
+ {
+-  static sd_hash_t* types = NULL;
+-  
+-  if (!types)
+-    types = sd_hash_new(20, NULL);
+-  
+-  return types;
++	if (!appender_types)
++		appender_types = sd_hash_new(20, NULL);
++
++	return appender_types;
+ }
+ 
+ extern void log4c_appender_types_free( void ) {
+-	sd_hash_t * types = log4c_appender_types();
+-	if ( types != NULL ) {
+-		sd_hash_delete( types );
++	if (appender_types) {
++		sd_hash_delete( appender_types );
++		appender_types = NULL;
+ 	}
+ }
+ 
+diff --git a/src/log4c/layout.c b/src/log4c/layout.c
+index 764b285..d260f7c 100644
+--- a/src/log4c/layout.c
++++ b/src/log4c/layout.c
+@@ -27,22 +27,21 @@ struct __log4c_layout
+ };
+ 
+ sd_factory_t* log4c_layout_factory = NULL;
++static sd_hash_t* layout_types = NULL;
+ 
+ /*******************************************************************************/
+ static sd_hash_t* log4c_layout_types(void)
+ {
+-    static sd_hash_t* types = NULL;
++	if (!layout_types)
++		layout_types = sd_hash_new(20, NULL);
+ 
+-    if (!types)
+-	types = sd_hash_new(20, NULL);
+-    
+-    return types;
++	return layout_types;
+ }
+ 
+ extern void log4c_layout_types_free( void ) {
+-	sd_hash_t * types = log4c_layout_types();
+-	if ( types != NULL ) {
+-		sd_hash_delete( types );
++	if (layout_types) {
++		sd_hash_delete( layout_types );
++		layout_types = NULL;
+ 	}
+ }
+ 
+diff --git a/src/log4c/rollingpolicy.c b/src/log4c/rollingpolicy.c
+index 3c445a2..ccec3da 100644
+--- a/src/log4c/rollingpolicy.c
++++ b/src/log4c/rollingpolicy.c
+@@ -30,21 +30,20 @@ struct __log4c_rollingpolicy
+ };
+ 
+ sd_factory_t* log4c_rollingpolicy_factory = NULL;
++static sd_hash_t* rollingpolicy_types = NULL;
+ 
+ /*******************************************************************************/
+ static sd_hash_t* log4c_rollingpolicy_types(void){
+-  static sd_hash_t* types = NULL;
+-  
+-  if (!types)
+-    types = sd_hash_new(20, NULL);
+-  
+-  return types;
++	if (!rollingpolicy_types)
++		rollingpolicy_types = sd_hash_new(20, NULL);
++
++	return rollingpolicy_types;
+ }
+ 
+ extern void log4c_rollingpolicy_types_free( void ) {
+-	sd_hash_t * types = log4c_rollingpolicy_types();
+-	if ( types != NULL ) {
+-		sd_hash_delete( types );
++	if (rollingpolicy_types) {
++		sd_hash_delete( rollingpolicy_types );
++		rollingpolicy_types = NULL;
+ 	}
+ }
+ 


More information about the scm-commits mailing list