diff --git a/antlr-libversion.diff b/antlr-libversion.diff index b87b13d..d220135 100644 --- a/antlr-libversion.diff +++ b/antlr-libversion.diff @@ -4,19 +4,29 @@ From: Jan Engelhardt "-avoid-version" does not count for compatibility guarantees. Use one of -version-info, -release or -Wl,--version-script! --- - Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Makefile.am | 2 +- + configure.ac | 2 ++ + 2 files changed, 3 insertions(+), 1 deletion(-) -Index: libantlr3c-3.4/Makefile.am -=================================================================== ---- libantlr3c-3.4.orig/Makefile.am -+++ libantlr3c-3.4/Makefile.am +--- a/Makefile.am ++++ b/Makefile.am @@ -62,7 +62,7 @@ include_HEADERS = include/antlr3.h include/antlr3treeparser.h \ antlr3config.h -libantlr3c_la_LDFLAGS = -avoid-version -+libantlr3c_la_LDFLAGS = -release ${PACKAGE_VERSION} ++libantlr3c_la_LDFLAGS = -version-info @LIB_VERSION@ INCLUDES = -Iinclude +--- a/configure.ac ++++ b/configure.ac +@@ -34,6 +34,8 @@ AC_COPYRIGHT([ + ]) + AC_CONFIG_SRCDIR(src/antlr3parser.c) + ++LIB_VERSION=`echo $PACKAGE_VERSION|sed 's@\.@:@g'` ++AC_SUBST([LIB_VERSION]) + + AC_ARG_ENABLE([debuginfo], + [AS_HELP_STRING([--enable-debuginfo], [Compiles debug info into the library (default --disable-debuginfo)])], diff --git a/antlr3c.changes b/antlr3c.changes index 19bbdca..fd0ace2 100644 --- a/antlr3c.changes +++ b/antlr3c.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Thu Jun 16 07:23:25 UTC 2016 - jslaby@suse.com + +- port patches from home:jirislaby:statica + * add baselibs.conf to have 32bit libs too + * add fix-LIST-memory-leak.patch + * add fix-hash-double-free.patch +- use standard library versioning and obsolete the old packages + ------------------------------------------------------------------- Sat Feb 6 12:00:03 UTC 2016 - mpluskal@suse.com diff --git a/antlr3c.spec b/antlr3c.spec index 95756fc..b244600 100644 --- a/antlr3c.spec +++ b/antlr3c.spec @@ -17,7 +17,7 @@ # -%define soname libantlr3c-3_4 +%define soname libantlr3c3 Name: antlr3c Version: 3.4 Release: 0 @@ -26,8 +26,10 @@ License: BSD-3-Clause Group: Development/Libraries/C and C++ Url: http://www.antlr3.org/ Source: http://www.antlr3.org/download/C/lib%{name}-%{version}.tar.gz +Patch0: fix-LIST-memory-leak.patch Patch1: antlr-64bit.diff Patch2: antlr-libversion.diff +Patch3: fix-hash-double-free.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: gcc @@ -48,6 +50,8 @@ Group: System/Libraries # From 13.3/TW201501 onwards Obsoletes: libantlr3c3_4 < %{version} Provides: libantlr3c3_4 = %{version} +Obsoletes: libantlr3c-3_4 < %{version} +Provides: libantlr3c-3_4 = %{version} %description -n %{soname} ANTLR, ANother Tool for Language Recognition, is a language tool that provides a @@ -73,8 +77,10 @@ develop programs using the antlr3c library. %prep %setup -q -n lib%{name}-%{version} +%patch0 -p1 %patch1 -p1 %patch2 -p1 +%patch3 -p1 %build autoreconf -fiv @@ -91,7 +97,7 @@ find %{buildroot} -type f -name "*.la" -delete -print %files -n %{soname} %defattr(-,root,root) -%{_libdir}/libantlr3c-%{version}.so +%{_libdir}/libantlr3c.so.* %files devel %defattr(-,root,root,-) diff --git a/baselibs.conf b/baselibs.conf new file mode 100644 index 0000000..2600f33 --- /dev/null +++ b/baselibs.conf @@ -0,0 +1 @@ +libantlr3c-3_4 diff --git a/fix-LIST-memory-leak.patch b/fix-LIST-memory-leak.patch new file mode 100644 index 0000000..501bf0c --- /dev/null +++ b/fix-LIST-memory-leak.patch @@ -0,0 +1,45 @@ +From 26aaa0f97e45025c48139bd39adc8808f9b4e697 Mon Sep 17 00:00:00 2001 +From: Jiri Slaby +Date: Thu, 17 Feb 2011 21:26:57 +0100 +Subject: [PATCH] collections: fix a LIST memory leak + +When using antlr3 lists, Valgrind reports leaks like this: +==30092== HEAP SUMMARY: +==30092== in use at exit: 80 bytes in 2 blocks +==30092== total heap usage: 286 allocs, 284 frees, 1,781,381 bytes allocated +==30092== +==30092== 40 bytes in 1 blocks are definitely lost in loss record 1 of 2 +==30092== at 0x4C2659D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) +==30092== by 0x4E333B8: antlr3HashPutI (antlr3collections.c:569) + +It's because we use HASH as a representation for LIST. The LIST +abstracts from HASH, so a user doesn't see a hash 'entry' itself. +Hence if the user do list->remove, the HASH returns an 'entry' to us +and we return entry->data to the user. But nobody frees the entry +itself. + +So free the entry from now on. + +Signed-off-by: Jiri Slaby +--- + src/antlr3collections.c | 4 +++- + 1 files changed, 3 insertions(+), 1 deletions(-) + +diff --git a/src/antlr3collections.c b/src/antlr3collections.c +index 48ffe18..01f3f7e 100644 +--- a/src/antlr3collections.c ++++ b/src/antlr3collections.c +@@ -946,7 +946,9 @@ antlr3ListRemove (pANTLR3_LIST list, ANTLR3_INTKEY key) + + if (entry != NULL) + { +- return entry->data; ++ void *data = entry->data; ++ ANTLR3_FREE(entry); ++ return data; + } + else + { +-- +1.7.3.4 + diff --git a/fix-hash-double-free.patch b/fix-hash-double-free.patch new file mode 100644 index 0000000..4515c08 --- /dev/null +++ b/fix-hash-double-free.patch @@ -0,0 +1,33 @@ +From 6f5dad7d06620b4665303c542549d4c14f9fe784 Mon Sep 17 00:00:00 2001 +From: Jiri Slaby +Date: Sat, 19 Feb 2011 13:26:35 +0100 +Subject: [PATCH] collections: hash, fix double free + +We should not free the hash entry in antlr3HashFree when we didn't +strdup on that earlier. + +I.e. make the free depend on table->doStrdup. + +Signed-off-by: Jiri Slaby +--- + src/antlr3collections.c | 4 +++- + 1 files changed, 3 insertions(+), 1 deletions(-) + +diff --git a/src/antlr3collections.c b/src/antlr3collections.c +index 01f3f7e..3e32dc3 100644 +--- a/src/antlr3collections.c ++++ b/src/antlr3collections.c +@@ -237,7 +237,9 @@ antlr3HashFree(pANTLR3_HASH_TABLE table) + */ + if (entry->keybase.type == ANTLR3_HASH_TYPE_STR && entry->keybase.key.sKey != NULL) + { +- ANTLR3_FREE(entry->keybase.key.sKey); ++ if (table->doStrdup == ANTLR3_TRUE) { ++ ANTLR3_FREE(entry->keybase.key.sKey); ++ } + } + + /* Free this entry +-- +1.7.3.4 +