Skip to content

Commit 3b034b8

Browse files
authored
Fix null pointer arithmetic UB in libregexp (#136)
This is a patch I originally wrote for the Kiesel JS engine: https://codeberg.org/kiesel-js/kiesel/src/branch/main/patches/libregexp.patch
1 parent f181b3e commit 3b034b8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libregexp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,9 +1199,10 @@ static int find_group_name(REParseState *s, const char *name)
11991199
size_t len, name_len;
12001200
int capture_index;
12011201

1202-
name_len = strlen(name);
12031202
p = (char *)s->group_names.buf;
1203+
if (!p) return -1;
12041204
buf_end = (char *)s->group_names.buf + s->group_names.size;
1205+
name_len = strlen(name);
12051206
capture_index = 1;
12061207
while (p < buf_end) {
12071208
len = strlen(p);

0 commit comments

Comments
 (0)