From 8966542658b8a6329dc26fe87396c3c3346c82e1 Mon Sep 17 00:00:00 2001 From: Darryl L. Pierce Date: Jan 28 2013 15:50:54 +0000 Subject: Fixed memory leak in Perl bindings typemap. - Resolves: BZ#885149 --- diff --git a/02-QPID-4493-Fixes-a-memory-leak-in-the-Perl-language-b.patch b/02-QPID-4493-Fixes-a-memory-leak-in-the-Perl-language-b.patch new file mode 100644 index 0000000..2e969b9 --- /dev/null +++ b/02-QPID-4493-Fixes-a-memory-leak-in-the-Perl-language-b.patch @@ -0,0 +1,55 @@ +From 1f70ff91f87cff4e78240d8288ab825a333a7f11 Mon Sep 17 00:00:00 2001 +From: "Darryl L. Pierce" +Date: Mon, 28 Jan 2013 14:25:50 +0000 +Subject: [PATCH] QPID-4493: Fixes a memory leak in the Perl language bindings. + +Replaces creating hashes and arrays using a scalar type with the +appropriate Perl API calls for creating a hash and an array. + +Submitted by: Jimmy Jones + +git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1439422 13f79535-47bb-0310-9956-ffa450edef68 +--- + qpid/cpp/bindings/swig_perl_typemaps.i | 12 ++++-------- + 1 file changed, 4 insertions(+), 8 deletions(-) + +diff --git a/qpid/cpp/bindings/swig_perl_typemaps.i b/qpid/cpp/bindings/swig_perl_typemaps.i +index 201e64b..f294183 100644 +--- a/qpid/cpp/bindings/swig_perl_typemaps.i ++++ b/qpid/cpp/bindings/swig_perl_typemaps.i +@@ -119,28 +119,24 @@ + } + + SV* MapToPerl(const qpid::types::Variant::Map* map) { +- SV *result = newSV(0); +- HV *hv = (HV *)sv_2mortal((SV *)newHV()); ++ HV *hv = newHV(); + qpid::types::Variant::Map::const_iterator iter; + for (iter = map->begin(); iter != map->end(); iter++) { + const std::string key(iter->first); + SV* perlval = VariantToPerl(&(iter->second)); + hv_store(hv, key.c_str(), key.size(), perlval, 0); + } +- SvSetSV(result, newRV_noinc((SV *)hv)); +- return result; ++ return sv_2mortal(newRV_noinc((SV *)hv)); + } + + SV* ListToPerl(const qpid::types::Variant::List* list) { +- SV* result = newSV(0); +- AV* av = (AV *)sv_2mortal((SV *)newAV()); ++ AV* av = newAV(); + qpid::types::Variant::List::const_iterator iter; + for (iter = list->begin(); iter != list->end(); iter++) { + SV* perlval = VariantToPerl(&(*iter)); + av_push(av, perlval); + } +- SvSetSV(result, newRV_noinc((SV *)av)); +- return result; ++ return sv_2mortal(newRV_noinc((SV *)av)); + } + + void PerlToMap(SV* hash, qpid::types::Variant::Map* map) { +-- +1.8.1 + diff --git a/qpid-cpp.spec b/qpid-cpp.spec index b16bca1..e8fa35b 100644 --- a/qpid-cpp.spec +++ b/qpid-cpp.spec @@ -30,7 +30,7 @@ Name: qpid-cpp Version: 0.20 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Libraries for Qpid C++ client applications License: ASL 2.0 URL: http://qpid.apache.org @@ -68,6 +68,7 @@ BuildRequires: libaio-devel Patch1: 01-Add-support-for-ARM-processors.patch +Patch2: 02-QPID-4493-Fixes-a-memory-leak-in-the-Perl-language-b.patch %description @@ -567,6 +568,9 @@ Management and diagnostic tools for Apache Qpid brokers and clients. %setup -q -n qpid-%{version} %setup -q -T -D -b 1 -n qpid-%{version} +%patch2 -p2 + +# qpid-store pushd ../store-%{version}.%{store_svnrev} %patch1 -p1 popd @@ -759,6 +763,10 @@ rm -rf %{buildroot} %changelog +* Mon Jan 28 2013 Darryl L. Pierce - 0.20-2 +- Fixed memory leak in Perl bindings typemap. +- Resolves: BZ#885149 + * Wed Jan 23 2013 Darryl L. Pierce - 0.20-1 - Rebased Qpid on release 0.20. - Rebased Store on SVN revision 4521.