aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/lua-lpeg
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-29 09:05:31 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-29 09:05:31 +0000
commit4e516ef44345e2f015572c83ba1bfb32f93c820a (patch)
tree7709cd4de4fff32ae1e3e5fca20c9bb47d55657f /contrib/lua-lpeg
parentea0584a431a49eb3fc682ccb3b8d6fc80a99db37 (diff)
downloadrspamd-4e516ef44345e2f015572c83ba1bfb32f93c820a.tar.gz
rspamd-4e516ef44345e2f015572c83ba1bfb32f93c820a.zip
[Minor] Fix asan friendliness in lpeg
Diffstat (limited to 'contrib/lua-lpeg')
-rw-r--r--contrib/lua-lpeg/lpvm.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/contrib/lua-lpeg/lpvm.c b/contrib/lua-lpeg/lpvm.c
index 4ef424579..6058bf5b1 100644
--- a/contrib/lua-lpeg/lpvm.c
+++ b/contrib/lua-lpeg/lpvm.c
@@ -306,27 +306,39 @@ const char *match (lua_State *L, const char *o, const char *s, const char *e,
continue;
}
case IChar: {
- if ((byte)*s == p->i.aux && s < e) { p++; s++; }
+ if (s < e && (byte)*s == p->i.aux) { p++; s++; }
else goto fail;
continue;
}
case ITestChar: {
- if ((byte)*s == p->i.aux && s < e) p += 2;
+ if (s < e && (byte)*s == p->i.aux) p += 2;
else p += getoffset(p);
continue;
}
case ISet: {
- int c = (byte)*s;
- if (testchar((p+1)->buff, c) && s < e)
- { p += CHARSETINSTSIZE; s++; }
- else goto fail;
+ if (s < e) {
+ int c = (byte) *s;
+ if (testchar((p + 1)->buff, c)) {
+ p += CHARSETINSTSIZE;
+ s++;
+ }
+ else goto fail;
+ }
+ else {
+ goto fail;
+ }
continue;
}
case ITestSet: {
- int c = (byte)*s;
- if (testchar((p + 2)->buff, c) && s < e)
- p += 1 + CHARSETINSTSIZE;
- else p += getoffset(p);
+ if (s < e) {
+ int c = (byte) *s;
+ if (testchar((p + 2)->buff, c))
+ p += 1 + CHARSETINSTSIZE;
+ else p += getoffset(p);
+ }
+ else {
+ p += getoffset(p);
+ }
continue;
}
case IBehind: {