From f625dd45448c1ebe0a4fe1949124c09dcfd34df1 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 17 Feb 2009 13:14:02 +0100 Subject: [PATCH] bindings/perl: Fix error handling in Perl:ping() and XS:_ping_iterator_get_hostname(). Signed-off-by: Florian Forster --- bindings/perl/Oping.xs | 3 +++ bindings/perl/lib/Net/Oping.pm | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) 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); -- 2.11.0