This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix on top of 75326c48.
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 11 Aug 2016 23:53:30 +0000 (19:53 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Fri, 12 Aug 2016 02:51:08 +0000 (22:51 -0400)
Worked partly accidentally, and as a bonus caused asan
off-stack-variable read violations.

sv.c
t/op/sprintf2.t

diff --git a/sv.c b/sv.c
index ce1a8ce..ae70d7b 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -12517,12 +12517,12 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
                             bool overflow = FALSE;
                             if (v0[precis + 1] < 0x8) {
                                 /* Round down, nothing to do. */
-                            } else if (v[precis + 1] > 0x8) {
+                            } else if (v0[precis + 1] > 0x8) {
                                 /* Round up. */
-                                v0[precis + 1]++;
-                                overflow = v0[precis + 1] > 0xF;
-                                v0[precis + 1] &= 0xF;
-                            } else { /* v[precis + 1] == 0x8 */
+                                v0[precis]++;
+                                overflow = v0[precis] > 0xF;
+                                v0[precis] &= 0xF;
+                            } else { /* v0[precis] == 0x8 */
                                 /* Half-point: round towards the one
                                  * with the even least-significant digit:
                                  * 08 -> 0  88 -> 8
index 2cf999d..d281850 100644 (file)
@@ -786,7 +786,7 @@ SKIP: {
        [ '3e-323', '%.4a', '0x1.8000p-1072' ],
        [ '3e-324', '%.4a', '0x1.0000p-1074' ],
        [ '3e-320', '%.1a', '0x1.8p-1062' ],
-       [ '3e-321', '%.1a', '0x1.2p-1065' ],
+       [ '3e-321', '%.1a', '0x1.3p-1065' ],
        [ '3e-322', '%.1a', '0x1.ep-1069' ],
        [ '3e-323', '%.1a', '0x1.8p-1072' ],
        [ '3e-324', '%.1a', '0x1.0p-1074' ],