summaryrefslogtreecommitdiffhomepage
path: root/lib.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-02-03 11:25:31 +0100
committerJo-Philipp Wich <jo@mein.io>2022-02-03 17:04:05 +0100
commit3ad57f116631029263cdbb324a20076006a94d4c (patch)
tree891c766a8d2a305d088e504fc06f9aa5ea952ae4 /lib.c
parent32d596da36758446331c4202dad9494329545ec2 (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.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index 6235470..ab04b32 100644
--- a/lib.c
+++ b/lib.c
@@ -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 {