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
This commit is contained in:
Linus Groh 2023-11-29 13:43:02 +00:00 committed by GitHub
parent f181b3e54f
commit 3b034b84d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1199,9 +1199,10 @@ static int find_group_name(REParseState *s, const char *name)
size_t len, name_len; size_t len, name_len;
int capture_index; int capture_index;
name_len = strlen(name);
p = (char *)s->group_names.buf; p = (char *)s->group_names.buf;
if (!p) return -1;
buf_end = (char *)s->group_names.buf + s->group_names.size; buf_end = (char *)s->group_names.buf + s->group_names.size;
name_len = strlen(name);
capture_index = 1; capture_index = 1;
while (p < buf_end) { while (p < buf_end) {
len = strlen(p); len = strlen(p);