bindings/perl: Fix error handling in Perl:ping() and XS:_ping_iterator_get_hostname().
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 17 Feb 2009 12:14:02 +0000 (13:14 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 17 Feb 2009 12:14:02 +0000 (13:14 +0100)
Signed-off-by: Florian Forster <octo@leeloo.lan.home.verplant.org>
bindings/perl/Oping.xs
bindings/perl/lib/Net/Oping.pm

index 6fbf49c..d97d4f8 100644 (file)
@@ -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);
index 1552ee9..838fb58 100644 (file)
@@ -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);