Code

bindings/perl: Fix a memory leak in _ping_iterator_get_hostname(). Net-Oping-1.02
authorFlorian Forster <octo@verplant.org>
Tue, 17 Feb 2009 07:50:06 +0000 (08:50 +0100)
committerFlorian Forster <octo@verplant.org>
Tue, 17 Feb 2009 07:53:56 +0000 (08:53 +0100)
Thanks to "Iceberg" who reported this issue and provided the patch via
rt.cpan.org.

Signed-off-by: Florian Forster <octo@verplant.org>
bindings/perl/Changes
bindings/perl/META.yml
bindings/perl/Oping.xs
bindings/perl/README
bindings/perl/lib/Net/Oping.pm

index 3840e4e78362675e083e15c797f220553c02b840..c46c003c804bbd92b6366eedabc290c54d647ec4 100644 (file)
@@ -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 <oping.h> cannot be found
          _before_ a Makefile is generated. This is done because
index 3351afd730f51121e75f9099678b75b05491b873..7a71aa69b115a20c6e47816bab0ed8fbcbe2b504 100644 (file)
@@ -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:
index 0cebf3d921ba6df3ba4470b3fc28a97d5dfb0ca2..6376775e022bb912d8067f712a96d2afac88e83d 100644 (file)
@@ -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)
index 2714e36b25d299b2cd0818b8b264c462458c6768..a550a723b47061c7204c21f05766e271023d6449 100644 (file)
@@ -1,4 +1,4 @@
-Net::Oping version 1.01
+Net::Oping version 1.02
 =======================
 
   ICMP latency measurement module using the oping library.
index aeeedf05306786e30e939e18e3f11477564dcc69..6c59ecb4b43fff70e78e580db472be9f2548fe05 100644 (file)
@@ -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);