Skip to content

Commit a21edf4

Browse files
committed
regexec trie: Use preferred utf8_to_uv()
Convert from using utf8n_to_uvchr() While we're at it, also die if the UTF-8 encountered is malformed.
1 parent 5626dfe commit a21edf4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

regexec.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,9 @@ STMT_START { \
18211821
case trie_utf8_fold: \
18221822
do_trie_utf8_fold: \
18231823
if ( foldlen > 0 ) { \
1824-
uvc = utf8n_to_uvchr( (const U8*) uscan, foldlen, &len, uniflags );\
1824+
(void) utf8_to_uv_flags( (const U8*) uscan, uscan + foldlen, \
1825+
&uvc, &len, \
1826+
(uniflags|UTF8_DIE_IF_MALFORMED)); \
18251827
foldlen -= len; \
18261828
uscan += len; \
18271829
len = 0; \
@@ -1843,7 +1845,9 @@ STMT_START { \
18431845
case trie_latin_utf8_fold: \
18441846
do_trie_latin_utf8_fold: \
18451847
if ( foldlen > 0 ) { \
1846-
uvc = utf8n_to_uvchr( (const U8*) uscan, foldlen, &len, uniflags );\
1848+
(void) utf8_to_uv_flags( (const U8*) uscan, uscan + foldlen, \
1849+
&uvc, &len, \
1850+
(uniflags|UTF8_DIE_IF_MALFORMED)); \
18471851
foldlen -= len; \
18481852
uscan += len; \
18491853
len = 0; \
@@ -1862,7 +1866,8 @@ STMT_START { \
18621866
} \
18631867
/* FALLTHROUGH */ \
18641868
case trie_utf8: \
1865-
uvc = utf8n_to_uvchr( (const U8*) uc, uc_end - uc, &len, uniflags );\
1869+
(void) utf8_to_uv_flags( (const U8*) uc, uc_end, &uvc, &len, \
1870+
(uniflags|UTF8_DIE_IF_MALFORMED)); \
18661871
break; \
18671872
case trie_plain: \
18681873
uvc = (UV)*uc; \

0 commit comments

Comments
 (0)