From: Florian Forster Date: Tue, 17 Feb 2009 07:50:06 +0000 (+0100) Subject: bindings/perl: Fix a memory leak in _ping_iterator_get_hostname(). X-Git-Tag: Net-Oping-1.02^0 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=9d8baf99b9327e832ce25c306f0ad63eabe035f6;p=liboping.git bindings/perl: Fix a memory leak in _ping_iterator_get_hostname(). Thanks to "Iceberg" who reported this issue and provided the patch via rt.cpan.org. Signed-off-by: Florian Forster --- diff --git a/bindings/perl/Changes b/bindings/perl/Changes index 3840e4e..c46c003 100644 --- a/bindings/perl/Changes +++ b/bindings/perl/Changes @@ -1,5 +1,9 @@ Revision history for Perl extension Net::Oping. +1.02 Tue Feb 17 08:52:25 2009 + - Fix a memory leak in _ping_iterator_get_hostname() [fixes RT#37066] + Thanks to "Iceberg" for reporting this issue and providing the patch. + 1.01 Sun Jan 27 16:08:03 2008 - Have `Makefile.PL' exit if the header file cannot be found _before_ a Makefile is generated. This is done because diff --git a/bindings/perl/META.yml b/bindings/perl/META.yml index 3351afd..7a71aa6 100644 --- a/bindings/perl/META.yml +++ b/bindings/perl/META.yml @@ -1,7 +1,7 @@ # http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Net-Oping -version: 1.01 +version: 1.02 version_from: lib/Net/Oping.pm installdirs: site requires: diff --git a/bindings/perl/Oping.xs b/bindings/perl/Oping.xs index 0cebf3d..6376775 100644 --- a/bindings/perl/Oping.xs +++ b/bindings/perl/Oping.xs @@ -105,16 +105,14 @@ _ping_iterator_get_latency (iter) OUTPUT: RETVAL -char * +void _ping_iterator_get_hostname (iter) pingobj_iter_t *iter - CODE: + PPCODE: char *buffer; size_t buffer_size; int status; - RETVAL = NULL; - do { buffer = NULL; buffer_size = 0; @@ -135,10 +133,9 @@ _ping_iterator_get_hostname (iter) if (status != 0) break; - RETVAL = buffer; + XPUSHs (sv_2mortal (newSVpvn(buffer,buffer_size))); + free(buffer); } while (0); - OUTPUT: - RETVAL const char * _ping_get_error (obj) diff --git a/bindings/perl/README b/bindings/perl/README index 2714e36..a550a72 100644 --- a/bindings/perl/README +++ b/bindings/perl/README @@ -1,4 +1,4 @@ -Net::Oping version 1.01 +Net::Oping version 1.02 ======================= ICMP latency measurement module using the oping library. diff --git a/bindings/perl/lib/Net/Oping.pm b/bindings/perl/lib/Net/Oping.pm index aeeedf0..6c59ecb 100644 --- a/bindings/perl/lib/Net/Oping.pm +++ b/bindings/perl/lib/Net/Oping.pm @@ -36,7 +36,7 @@ use warnings; use Carp (qw(cluck confess)); -our $VERSION = '1.01'; +our $VERSION = '1.02'; require XSLoader; XSLoader::load ('Net::Oping', $VERSION);