From 1de57f991a98d99872c5edb5200ca8309126187d Mon Sep 17 00:00:00 2001 From: Reyk Floeter Date: Sat, 20 Jun 2015 22:18:03 +0200 Subject: Changing luaL_error() calls to match_error() required slightly different semantics as we cannot just abort as Lua does. So we have to check return values carefully and I missed a few in the transition. Patch by Sebastien Marie --- httpd/patterns.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/httpd/patterns.c b/httpd/patterns.c index 23c7083..f4b999d 100644 --- a/httpd/patterns.c +++ b/httpd/patterns.c @@ -275,8 +275,10 @@ start_capture(struct match_state *ms, const char *s, const char *p, int what) const char *res; int level = ms->level; - if (level >= ms->maxcaptures) + if (level >= ms->maxcaptures) { match_error(ms, "too many captures"); + return (NULL); + } ms->capture[level].init = s; ms->capture[level].len = what; ms->level = level + 1; @@ -320,8 +322,10 @@ match(struct match_state *ms, const char *s, const char *p) const char *ep, *res; char previous; - if (ms->matchdepth-- == 0) + if (ms->matchdepth-- == 0) { match_error(ms, "pattern too complex"); + return (NULL); + } /* using goto's to optimize tail recursion */ init: @@ -364,9 +368,11 @@ match(struct match_state *ms, const char *s, const char *p) case 'f': /* frontier? */ p += 2; - if (*p != '[') + if (*p != '[') { match_error(ms, "missing '['" " after '%%f' in pattern"); + break; + } /* points to what is next */ ep = classend(ms, p); previous = @@ -518,7 +524,7 @@ push_onecapture(struct match_state *ms, int i, const char *s, } else { ptrdiff_t l = ms->capture[i].len; if (l == CAP_UNFINISHED) - match_error(ms, "unfinished capture"); + return match_error(ms, "unfinished capture"); sm->sm_so = ms->capture[i].init - ms->src_init; sm->sm_eo = sm->sm_so + l; } -- cgit v1.2.3-54-g00ecf