Skip Menu |

This queue is for tickets about the Net-Oping CPAN distribution.

Report information
The Basics
Id: 37066
Status: resolved
Priority: 0/
Queue: Net-Oping

People
Owner: octopus [...] nospam.verplant.org
Requestors: rafal [...] krypa.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 1.00
  • 1.01
Fixed in: 1.02



Subject: Memory leak in _ping_iterator_get_hostname()
It seems, that Perl's GC is not taking care of memory allocated for the buffer in _ping_iterator_get_hostname() by malloc() function call. While pointer to the buffer is returned from the function, it is never freed and thus a memory leak occurs. Please see the patch attached that seem to fix the problem. My environment: Perl 5.10.0 Linux 2.6.25.2 Debian testing/unstable
Subject: net-oping.diff
diff -urN a/Oping.xs b/Oping.xs --- a/Oping.xs 2008-01-26 13:59:18.000000000 +0100 +++ b/Oping.xs 2008-06-24 18:40:03.000000000 +0200 @@ -105,16 +105,14 @@ 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,10 @@ 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)
RT-Send-CC: liboping [...] verplant.org
Hi, thank you very much for you bug report and sorry I missed it :/ I've just uploaded version 1.02 of Net::Oping which includes your patch :) Best regards, -octo