diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-02-03 11:25:31 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-02-03 17:04:05 +0100 |
commit | 3ad57f116631029263cdbb324a20076006a94d4c (patch) | |
tree | 891c766a8d2a305d088e504fc06f9aa5ea952ae4 /lib.c | |
parent | 32d596da36758446331c4202dad9494329545ec2 (diff) |
lib: fix infinite loop on empty regexp matches in uc_match()
The regular expression `/()/` will match the empty string, causing the
match loop to never advance. Add extra logic to deal with this case.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -1804,7 +1804,13 @@ uc_match(uc_vm_t *vm, size_t nargs) ucv_array_push(rv, m); - p += pmatch[0].rm_eo; + if (pmatch[0].rm_so != pmatch[0].rm_eo) + p += pmatch[0].rm_eo; + else if (*p) + p++; + else + break; + eflags |= REG_NOTBOL; } else { |