Introduction
Introduction Statistics Contact Development Disclaimer Help
tregex: more resistance to bad patterns - neatvi - [fork] simple vi-type editor…
git clone git://src.adamsgaard.dk/neatvi
Log
Files
Refs
README
---
commit 084f80f48593acb03934dc61631b045ca5c65026
parent e14f2566479bd4cb53821e13d0518b11e4b89b94
Author: Ali Gholami Rudi <[email protected]>
Date: Mon, 22 Jun 2015 23:02:23 +0430
regex: more resistance to bad patterns
Diffstat:
M regex.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/regex.c b/regex.c
t@@ -312,6 +312,8 @@ static struct rnode *rnode_grp(char **pat)
return NULL;
*pat += 1;
rnode = rnode_parse(pat);
+ if (!rnode)
+ return NULL;
if ((*pat)[0] != ')') {
rnode_free(rnode);
return NULL;
t@@ -333,6 +335,8 @@ static struct rnode *rnode_atom(char **pat)
rnode = rnode_make(RN_ATOM, NULL, NULL);
ratom_read(&rnode->ra, pat);
}
+ if (!rnode)
+ return NULL;
if ((*pat)[0] == '*' || (*pat)[0] == '?') {
rnode->mincnt = 0;
rnode->maxcnt = (*pat)[0] == '*' ? -1 : 1;
t@@ -494,9 +498,12 @@ static void rnode_emit(struct rnode *n, struct regex *p)
int regcomp(regex_t *preg, char *pat, int flg)
{
struct rnode *rnode = rnode_parse(&pat);
- struct regex *re = malloc(sizeof(*re));
+ struct regex *re;
int n = rnode_count(rnode) + 3;
int mark;
+ if (!rnode)
+ return 1;
+ re = malloc(sizeof(*re));
memset(re, 0, sizeof(*re));
re->p = malloc(n * sizeof(re->p[0]));
memset(re->p, 0, n * sizeof(re->p[0]));
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.