From: Slaven Rezic Date: Sat, 1 Aug 1998 13:38:03 +0000 (+0200) Subject: fix quoting of keys with embedded nulls X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6c1ab3c2c17f75c79d85b1f973965af56233f51c;p=p5sagit%2Fp5-mst-13.2.git fix quoting of keys with embedded nulls Message-Id: <199808011138.NAA05189@mail.cs.tu-berlin.de> Subject: Data::Dumper 2.09, patch p4raw-id: //depot/maint-5.005/perl@1706 --- diff --git a/ext/Data/Dumper/Dumper.xs b/ext/Data/Dumper/Dumper.xs index 6add52f..d8012ee 100644 --- a/ext/Data/Dumper/Dumper.xs +++ b/ext/Data/Dumper/Dumper.xs @@ -5,7 +5,7 @@ static SV *freezer; static SV *toaster; -static I32 num_q _((char *s)); +static I32 num_q _((char *s, STRLEN slen)); static I32 esc_q _((char *dest, char *src, STRLEN slen)); static SV *sv_x _((SV *sv, char *str, STRLEN len, I32 n)); static I32 DD_dump _((SV *val, char *name, STRLEN namelen, SV *retval, @@ -42,14 +42,15 @@ TOP: /* count the number of "'"s and "\"s in string */ static I32 -num_q(register char *s) +num_q(register char *s, register STRLEN slen) { register I32 ret = 0; - - while (*s) { + + while (slen > 0) { if (*s == '\'' || *s == '\\') ++ret; ++s; + --slen; } return ret; } @@ -380,7 +381,7 @@ DD_dump(SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv, hval = hv_iterval((HV*)ival, entry); if (quotekeys || needs_quote(key)) { - nticks = num_q(key); + nticks = num_q(key, klen); New(0, nkey, klen+nticks+3, char); nkey[0] = '\''; if (nticks)