Change 34140 by [EMAIL PROTECTED] on 2008/07/13 21:37:21

        Make format items @* and ^* work with references (safely). Note no-one
        said anything about sanely.

Affected files ...

... //depot/perl/pp_ctl.c#698 edit
... //depot/perl/t/op/write.t#53 edit

Differences ...

==== //depot/perl/pp_ctl.c#698 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#697~34139~    2008-07-13 14:02:43.000000000 -0700
+++ perl/pp_ctl.c       2008-07-13 14:37:21.000000000 -0700
@@ -773,7 +773,7 @@
                if (itemsize) {
                    STRLEN to_copy = itemsize;
                    const char *const send = s + len;
-                   const U8 *source;
+                   const U8 *source = (const U8 *) s;
                    U8 *tmp = NULL;
 
                    gotsome = TRUE;
@@ -794,7 +794,7 @@
                        }
                    }
                    if (targ_is_utf8 && !item_is_utf8) {
-                       source = tmp = bytes_to_utf8((U8*)SvPVX(sv), &to_copy);
+                       source = tmp = bytes_to_utf8(source, &to_copy);
                        SvCUR_set(PL_formtarget,
                                  t - SvPVX_const(PL_formtarget));
                    } else {
@@ -810,7 +810,6 @@
                            SvCUR_set(PL_formtarget,
                                      t - SvPVX_const(PL_formtarget));
                        }
-                       source = (U8 *) SvPVX(sv);
 
                        /* Easy. They agree.  */
                        assert (item_is_utf8 == targ_is_utf8);

==== //depot/perl/t/op/write.t#53 (xtext) ====
Index: perl/t/op/write.t
--- perl/t/op/write.t#52~34139~ 2008-07-13 14:02:43.000000000 -0700
+++ perl/t/op/write.t   2008-07-13 14:37:21.000000000 -0700
@@ -61,7 +61,7 @@
 my $bas_tests = 20;
 
 # number of tests in section 3
-my $bug_tests = 4 + 3 * 3 * 5 * 2 * 3;
+my $bug_tests = 4 + 3 * 3 * 5 * 2 * 3 + 2;
 
 # number of tests in section 4
 my $hmb_tests = 35;
@@ -569,6 +569,15 @@
   }
 }
 
+{
+  # This will fail an assertion in 5.10.0 built with -DDEBUGGING (because
+  # pp_formline attempts to set SvCUR() on an SVt_RV). I suspect that it will
+  # be doing something similarly out of bounds on everything from 5.000
+  my $ref = [];
+  is swrite('>^*<', $ref), ">$ref<";
+  is swrite('>@*<', $ref), ">$ref<";
+}
+
 format EMPTY =
 .
 
End of Patch.

Reply via email to