From e3c500e6fef550f8f2d9cab5768fc464000660d1 Mon Sep 17 00:00:00 2001 From: Peter Schiffer Date: Tue, 19 Mar 2013 17:29:06 +0100 Subject: [PATCH] - fixed memory leaks detected by valgrind --- libpipeline-1.2.2-valgrind.patch | 76 ++++++++++++++++++++++++++++++++ libpipeline.spec | 12 +++-- 2 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 libpipeline-1.2.2-valgrind.patch diff --git a/libpipeline-1.2.2-valgrind.patch b/libpipeline-1.2.2-valgrind.patch new file mode 100644 index 0000000..493ec1d --- /dev/null +++ b/libpipeline-1.2.2-valgrind.patch @@ -0,0 +1,76 @@ +diff -upr libpipeline-1.2.2.orig/lib/pipeline.c libpipeline-1.2.2/lib/pipeline.c +--- libpipeline-1.2.2.orig/lib/pipeline.c 2013-03-13 10:23:09.000000000 +0100 ++++ libpipeline-1.2.2/lib/pipeline.c 2013-03-13 14:04:12.112208797 +0100 +@@ -255,6 +255,7 @@ pipecmd *pipecmd_new_argstr (const char + * work when being executed directly. To work around this, + * we just drop "exec" if it appears at the start of argstr. + */ ++ free (arg); + arg = argstr_get_word (&argstr); + if (!arg) + error (FATAL, 0, +diff -upr libpipeline-1.2.2.orig/tests/argstr.c libpipeline-1.2.2/tests/argstr.c +--- libpipeline-1.2.2.orig/tests/argstr.c 2010-10-29 04:08:04.000000000 +0200 ++++ libpipeline-1.2.2/tests/argstr.c 2013-03-13 12:00:58.310964032 +0100 +@@ -62,6 +62,7 @@ START_TEST (test_argstr_exec) + fail_unless (cmd->u.process.argc == 2); + fail_unless (!strcmp (cmd->u.process.argv[0], "foo")); + fail_unless (!strcmp (cmd->u.process.argv[1], "bar")); ++ pipecmd_free (cmd); + } + END_TEST + +diff -upr libpipeline-1.2.2.orig/tests/basic.c libpipeline-1.2.2/tests/basic.c +--- libpipeline-1.2.2.orig/tests/basic.c 2011-09-26 12:04:34.000000000 +0200 ++++ libpipeline-1.2.2/tests/basic.c 2013-03-13 14:11:52.891928581 +0100 +@@ -101,6 +101,7 @@ START_TEST (test_basic_wait_all) + fail_unless (statuses[1] == 3 * 256); + fail_unless (statuses[2] == 0); + pipeline_free (p); ++ free (statuses); + } + END_TEST + +@@ -200,6 +201,8 @@ START_TEST (test_basic_clearenv) + "clearenv+setenv+dup returned second line '%s', expected 'bar\n'", + line2); + pipeline_wait (p2); ++ pipeline_free (p2); ++ pipeline_free (p); + } + END_TEST + +diff -upr libpipeline-1.2.2.orig/tests/exec.c libpipeline-1.2.2/tests/exec.c +--- libpipeline-1.2.2.orig/tests/exec.c 2012-02-27 23:00:53.000000000 +0100 ++++ libpipeline-1.2.2/tests/exec.c 2013-03-13 12:11:15.498591343 +0100 +@@ -71,6 +71,8 @@ START_TEST (test_exec_process) + fail_unless (WEXITSTATUS (status) == i); + else + fail_if (WEXITSTATUS (status) == 0); ++ ++ pipecmd_free (cmd); + } + } + END_TEST +@@ -109,6 +111,8 @@ START_TEST (test_exec_function) + + fail_unless (WIFEXITED (status)); + fail_unless (WEXITSTATUS (status) == i); ++ ++ pipecmd_free (cmd); + } + } + END_TEST +diff -upr libpipeline-1.2.2.orig/tests/redirect.c libpipeline-1.2.2/tests/redirect.c +--- libpipeline-1.2.2.orig/tests/redirect.c 2012-02-29 19:23:59.000000000 +0100 ++++ libpipeline-1.2.2/tests/redirect.c 2013-03-13 14:10:05.601323557 +0100 +@@ -56,6 +56,9 @@ START_TEST (test_redirect_files) + + fclose (fh); + unlink (template); ++ ++ pipeline_free(p); ++ free (template); + } + END_TEST + diff --git a/libpipeline.spec b/libpipeline.spec index 1a1e8d8..59f417f 100644 --- a/libpipeline.spec +++ b/libpipeline.spec @@ -3,14 +3,16 @@ Summary: A pipeline manipulation library Name: libpipeline Version: 1.2.2 -Release: 3%{?dist} +Release: 4%{?dist} License: GPLv3+ Group: Development/Libraries URL: http://libpipeline.nongnu.org/ Source: http://download.savannah.gnu.org/releases/libpipeline/libpipeline-%{version}.tar.gz # resolves: #876108 -Patch: libpipeline-1.2.2-peek-offset.patch +Patch0: libpipeline-1.2.2-peek-offset.patch +# fixed memory leaks detected by valgrind +Patch1: libpipeline-1.2.2-valgrind.patch BuildRequires: libtool, check-devel @@ -36,7 +38,8 @@ to develop programs that use libpipeline library. %prep %setup -q -%patch -p1 -b .peek-offset +%patch0 -p1 -b .peek-offset +%patch1 -p1 -b .valgrind-mem %build %{configure} @@ -64,6 +67,9 @@ rm $RPM_BUILD_ROOT/%{_libdir}/libpipeline.la %{_mandir}/man3/* %changelog +* Tue Mar 19 2013 Peter Schiffer - 1.2.2-4 +- fixed memory leaks detected by valgrind + * Thu Feb 14 2013 Fedora Release Engineering - 1.2.2-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild