In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/e9f2c446ed77eec13aad13748ac1b503b0cc3304?hp=8ef45c1894ac4415a7d048c2354037573d69a106>

- Log -----------------------------------------------------------------
commit e9f2c446ed77eec13aad13748ac1b503b0cc3304
Author: Karl Williamson <[email protected]>
Date:   Mon Mar 6 12:25:21 2017 -0700

    utf8.c: Don't use Newx in decoding UTF-8
    
    The bottom level UTF-8 decoding routine can be used during periods when
    using Newx is prohibited, as diagnosed by Dave Mitchell for perl #130921
    (see that ticket for his explanation).
    
    This particular use of Newx was unnecessary, as it is just large enough
    to hold a single character, and that can be done by an automatic
    variable on the C stack.  The variable is used only upon rare error
    conditions, but its only 14 bytes (15 on EBCDIC).
-----------------------------------------------------------------------

Summary of changes:
 utf8.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/utf8.c b/utf8.c
index 89c8413f7c..4949bf6584 100644
--- a/utf8.c
+++ b/utf8.c
@@ -1079,6 +1079,8 @@ Perl_utf8n_to_uvchr_error(pTHX_ const U8 *s,
     U8 * adjusted_s0 = (U8 *) s0;
     U8 * adjusted_send = NULL;  /* (Initialized to silence compilers' wrong
                                    warning) */
+    U8 temp_char_buf[UTF8_MAXBYTES + 1]; /* Used to avoid a Newx in this
+                                            routine; see [perl #130921] */
     UV uv_so_far = 0;   /* (Initialized to silence compilers' wrong warning) */
 
     PERL_ARGS_ASSERT_UTF8N_TO_UVCHR_ERROR;
@@ -1245,10 +1247,7 @@ Perl_utf8n_to_uvchr_error(pTHX_ const U8 *s,
                                      I8_TO_NATIVE_UTF8(UTF_CONTINUATION_MARK));
             }
 
-            Newx(adjusted_s0, OFFUNISKIP(min_uv) + 1, U8);
-            SAVEFREEPV((U8 *) adjusted_s0);    /* Needed because we may not get
-                                                  to free it ourselves if
-                                                  warnings are made fatal */
+            adjusted_s0 = temp_char_buf;
             adjusted_send = uvoffuni_to_utf8_flags(adjusted_s0, min_uv, 0);
         }
     }

--
Perl5 Master Repository

Reply via email to