From: Fredrik Soderblom Date: Thu, 1 Oct 2009 12:24:46 +0000 (+0200) Subject: bindings/perl/Oping.xs: Fix an off-by-one error when allocating a Perl string. X-Git-Tag: liboping-1.3.4~3 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=40b25e68fc4d7d77bb8968bb1961f69689b8a30e;p=liboping.git bindings/perl/Oping.xs: Fix an off-by-one error when allocating a Perl string. In the previous code the null byte was included in the Perl string, making the string handling awkward. --- diff --git a/bindings/perl/Oping.xs b/bindings/perl/Oping.xs index 6106e13..5731d3d 100644 --- a/bindings/perl/Oping.xs +++ b/bindings/perl/Oping.xs @@ -183,8 +183,9 @@ _ping_iterator_get_hostname (iter) free (buffer); break; } + buffer[buffer_size - 1] = 0; - XPUSHs (sv_2mortal (newSVpvn(buffer,buffer_size))); + XPUSHs (sv_2mortal (newSVpvn(buffer, strlen (buffer)))); free(buffer); } while (0);