Skip to content

Commit 7fe1973

Browse files
committed
S_scan_const: Use utf8_to_uv_or_die not utf8n_to_uvchr
This will now croak if the input is malformed instead of wrongly turning it into a NUL.
1 parent c2ae512 commit 7fe1973

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

toke.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4155,10 +4155,10 @@ S_scan_const(pTHX_ char *start)
41554155
char hex_string[2 * UTF8_MAXBYTES + 5];
41564156

41574157
/* Get the first character of the result. */
4158-
U32 uv = utf8n_to_uvchr((U8 *) str,
4159-
len,
4160-
&char_length,
4161-
UTF8_ALLOW_ANYUV);
4158+
U32 uv = utf8_to_uv_or_die(
4159+
(const U8 *) str,
4160+
(const U8 *) str_end,
4161+
&char_length);
41624162
/* Convert first code point to Unicode hex,
41634163
* including the boiler plate before it. */
41644164
output_length =
@@ -4179,10 +4179,10 @@ S_scan_const(pTHX_ char *start)
41794179
* its Unicode code point in hex */
41804180
while ((str += char_length) < str_end) {
41814181
const STRLEN off = d - SvPVX_const(sv);
4182-
U32 uv = utf8n_to_uvchr((U8 *) str,
4183-
str_end - str,
4184-
&char_length,
4185-
UTF8_ALLOW_ANYUV);
4182+
U32 uv = utf8_to_uv_or_die(
4183+
(const U8 *) str,
4184+
(const U8 *) str_end,
4185+
&char_length);
41864186
output_length =
41874187
my_snprintf(hex_string,
41884188
sizeof(hex_string),

0 commit comments

Comments
 (0)