Skip to content

Commit 7bd1ae2

Browse files
author
Fabrice Bellard
committed
\x{N} is a syntax error
1 parent 31ef02b commit 7bd1ae2

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

libregexp.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -757,9 +757,21 @@ int lre_parse_escape(const uint8_t **pp, int allow_utf16)
757757
c = '\v';
758758
break;
759759
case 'x':
760+
{
761+
int h0, h1;
762+
763+
h0 = from_hex(*p++);
764+
if (h0 < 0)
765+
return -1;
766+
h1 = from_hex(*p++);
767+
if (h1 < 0)
768+
return -1;
769+
c = (h0 << 4) | h1;
770+
}
771+
break;
760772
case 'u':
761773
{
762-
int h, n, i;
774+
int h, i;
763775
uint32_t c1;
764776

765777
if (*p == '{' && allow_utf16) {
@@ -777,14 +789,8 @@ int lre_parse_escape(const uint8_t **pp, int allow_utf16)
777789
}
778790
p++;
779791
} else {
780-
if (c == 'x') {
781-
n = 2;
782-
} else {
783-
n = 4;
784-
}
785-
786792
c = 0;
787-
for(i = 0; i < n; i++) {
793+
for(i = 0; i < 4; i++) {
788794
h = from_hex(*p++);
789795
if (h < 0) {
790796
return -1;

0 commit comments

Comments
 (0)