diff options
author | Hugo van der Sanden <hv@crypt.org> | 2019-04-09 14:27:41 +0100 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2019-06-03 14:46:19 +1000 |
commit | b0f5b1daacb21ab7e46a772a6ff0f70ca627cb58 (patch) | |
tree | 9b53607f6e3b73908da831ed4068c1d1ea6acfe2 /sv.c | |
parent | 0dd3e67ea7cc472669925a46c372becbd5df557a (diff) | |
download | perl-b0f5b1daacb21ab7e46a772a6ff0f70ca627cb58.tar.gz |
[#134008] More carefully ignore negative precision in sprintf
Check has_precis more consistently; ensure precis is left as 0 if provided
as a negative number.
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -11765,11 +11765,11 @@ S_format_hexfp(pTHX_ char * const buf, const STRLEN bufsize, const char c, else { *p++ = '0'; exponent = 0; - zerotail = precis; + zerotail = has_precis ? precis : 0; } /* The radix is always output if precis, or if alt. */ - if (precis > 0 || alt) { + if ((has_precis && precis > 0) || alt) { hexradix = TRUE; } @@ -12223,6 +12223,9 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p } precis = S_sprintf_arg_num_val(aTHX_ args, i, sv, &neg); has_precis = !neg; + /* ignore negative precision */ + if (!has_precis) + precis = 0; } } else { |