Add patch to fix memory leak

This commit is contained in:
Sandro Mani 2019-06-28 13:00:21 +02:00
parent 67e029f044
commit 3791a18b5b
3 changed files with 67 additions and 3 deletions

View File

@ -1,6 +1,6 @@
Name: enchant2
Version: 2.2.4
Release: 1%{?snap}%{?dist}
Release: 2%{?snap}%{?dist}
Summary: An Enchanting Spell Checking Library
License: LGPLv2+
@ -10,6 +10,9 @@ Source0: https://github.com/AbiWord/enchant/releases/download/v%{version}/
# Look for aspell using pkg-config, instead of AC_CHECK_LIB which adds -laspell
# to the global LIBS and over-links libenchant (#1574893)
Patch0: enchant_aspell.patch
# Fix memory leaks (#1718084)
# https://github.com/AbiWord/enchant/issues/215
Patch1: enchant_mem-leaks.patch
BuildRequires: automake autoconf libtool
@ -63,6 +66,7 @@ autoreconf -ifv
%configure \
--with-aspell \
--with-hunspell-dir=%{_datadir}/myspell \
--without-hspell \
--disable-static
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g;
s|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
@ -101,6 +105,10 @@ find %{buildroot} -name '*.la' -delete
%changelog
* Fri Jun 28 2019 Sandro Mani <manisandro@gmail.com> - 2.2.4-2
- Add patch to fix memory leaks (#1718084)
- Pass --without-hspell
* Tue Jun 18 2019 Sandro Mani <manisandro@gmail.com> - 2.2.4-1
- Update to 2.2.4

View File

@ -1,6 +1,6 @@
diff -rupN enchant-2.2.4/configure.ac enchant-2.2.4-new/configure.ac
--- enchant-2.2.4/configure.ac 2019-06-17 19:43:56.000000000 +0200
+++ enchant-2.2.4-new/configure.ac 2019-06-18 09:47:01.726766653 +0200
+++ enchant-2.2.4-new/configure.ac 2019-06-28 12:54:47.034512442 +0200
@@ -269,7 +269,7 @@ build_providers=
dnl Standard providers
@ -12,7 +12,7 @@ diff -rupN enchant-2.2.4/configure.ac enchant-2.2.4-new/configure.ac
dnl FIXME: The test below assumes GCC(-compatible) ObjC++ compiler, but
diff -rupN enchant-2.2.4/providers/Makefile.am enchant-2.2.4-new/providers/Makefile.am
--- enchant-2.2.4/providers/Makefile.am 2017-12-12 13:22:28.000000000 +0100
+++ enchant-2.2.4-new/providers/Makefile.am 2019-06-18 09:47:01.726766653 +0200
+++ enchant-2.2.4-new/providers/Makefile.am 2019-06-28 12:54:47.034512442 +0200
@@ -12,6 +12,7 @@ AM_LDFLAGS = -module -avoid-version -no-
if WITH_ASPELL
provider_LTLIBRARIES += enchant_aspell.la
@ -21,3 +21,9 @@ diff -rupN enchant-2.2.4/providers/Makefile.am enchant-2.2.4-new/providers/Makef
if WITH_HSPELL
provider_LTLIBRARIES += enchant_hspell.la
diff -rupN enchant-2.2.4/tests/test.pwl.orig enchant-2.2.4-new/tests/test.pwl.orig
--- enchant-2.2.4/tests/test.pwl.orig 2017-02-04 18:34:34.000000000 +0100
+++ enchant-2.2.4-new/tests/test.pwl.orig 1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-hello
-tag

50
enchant_mem-leaks.patch Normal file
View File

@ -0,0 +1,50 @@
diff -rupN enchant-2.2.4/providers/enchant_hunspell.cpp enchant-2.2.4-new/providers/enchant_hunspell.cpp
--- enchant-2.2.4/providers/enchant_hunspell.cpp 2017-12-17 21:08:34.000000000 +0100
+++ enchant-2.2.4-new/providers/enchant_hunspell.cpp 2019-06-28 12:54:47.053512522 +0200
@@ -181,25 +181,34 @@ s_buildDictionaryDirs (std::vector<std::
{
dirs.clear ();
+ gchar * tmp;
char * config_dir = enchant_get_user_config_dir ();
- dirs.push_back (g_build_filename (config_dir, "hunspell", nullptr));
+ tmp = g_build_filename (config_dir, "hunspell", nullptr);
+ dirs.push_back (tmp);
free (config_dir);
+ g_free(tmp);
for (const gchar* const * iter = g_get_system_data_dirs (); *iter; iter++)
{
- dirs.push_back (g_build_filename (*iter, "hunspell", nullptr));
+ tmp = g_build_filename (*iter, "hunspell", nullptr);
+ dirs.push_back (tmp);
+ g_free(tmp);
}
/* Dynamically locate library and search for modules relative to it. */
char * enchant_prefix = enchant_get_prefix_dir();
if(enchant_prefix)
{
- dirs.push_back (g_build_filename(enchant_prefix, "share", "enchant", "hunspell", nullptr));
+ tmp = g_build_filename(enchant_prefix, "share", "enchant", "hunspell", nullptr);
+ dirs.push_back (tmp);
g_free(enchant_prefix);
+ g_free(tmp);
}
#ifdef ENCHANT_HUNSPELL_DICT_DIR
- dirs.push_back (enchant_relocate (ENCHANT_HUNSPELL_DICT_DIR));
+ config_dir = enchant_relocate (ENCHANT_HUNSPELL_DICT_DIR);
+ dirs.push_back (config_dir);
+ free(config_dir);
#endif
}
@@ -286,6 +295,7 @@ hunspell_request_dictionary (const char
g_dir_close (dir);
return dict;
}
+ g_free(dict);
}
}