From: Florian Forster Date: Tue, 17 Feb 2009 12:14:02 +0000 (+0100) Subject: bindings/perl: Fix error handling in Perl:ping() and XS:_ping_iterator_get_hostname(). X-Git-Tag: liboping-1.0.0~10 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=f625dd45448c1ebe0a4fe1949124c09dcfd34df1;p=liboping.git bindings/perl: Fix error handling in Perl:ping() and XS:_ping_iterator_get_hostname(). Signed-off-by: Florian Forster --- diff --git a/bindings/perl/Oping.xs b/bindings/perl/Oping.xs index 6fbf49c..d97d4f8 100644 --- a/bindings/perl/Oping.xs +++ b/bindings/perl/Oping.xs @@ -132,7 +132,10 @@ _ping_iterator_get_hostname (iter) status = ping_iterator_get_info (iter, PING_INFO_HOSTNAME, (void *) buffer, &buffer_size); if (status != 0) + { + free (buffer); break; + } XPUSHs (sv_2mortal (newSVpvn(buffer,buffer_size))); free(buffer); diff --git a/bindings/perl/lib/Net/Oping.pm b/bindings/perl/lib/Net/Oping.pm index 1552ee9..838fb58 100644 --- a/bindings/perl/lib/Net/Oping.pm +++ b/bindings/perl/lib/Net/Oping.pm @@ -231,12 +231,17 @@ sub ping $status = _ping_send ($obj->{'c_obj'}); if ($status < 0) { - print "\$status = $status;\n"; $obj->{'err_msg'} = "" . _ping_get_error ($obj->{'c_obj'}); return; } $iter = _ping_iterator_get ($obj->{'c_obj'}); + if (!$iter) + { + $obj->{'err_msg'} = "" . _ping_get_error ($obj->{'c_obj'}); + return; + } + while ($iter) { my $host = _ping_iterator_get_hostname ($iter);