From 6fa37b884913b9fb17567a2c595b7d9d228db9d1 Mon Sep 17 00:00:00 2001 From: pfg Date: Fri, 20 Feb 2015 21:21:38 +0000 Subject: regex(3): Fix uninitialized pointer values. CID: 405582 (also clang static checker) CID: 1018724 --- lib/libc/regex/engine.c | 2 +- lib/libc/regex/regcomp.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/libc/regex') diff --git a/lib/libc/regex/engine.c b/lib/libc/regex/engine.c index 589bb9d..8fc67ce 100644 --- a/lib/libc/regex/engine.c +++ b/lib/libc/regex/engine.c @@ -157,7 +157,7 @@ matcher(struct re_guts *g, int i; struct match mv; struct match *m = &mv; - const char *dp; + const char *dp = NULL; const sopno gf = g->firststate+1; /* +1 for OEND */ const sopno gl = g->laststate; const char *start; diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index ae92f6a..2da5066 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -1422,8 +1422,8 @@ static void findmust(struct parse *p, struct re_guts *g) { sop *scan; - sop *start; - sop *newstart; + sop *start = NULL; + sop *newstart = NULL; sopno newlen; sop s; char *cp; -- cgit v1.1 From 9705f06cfe0559e4bbc5264a5c725302bb4f2eec Mon Sep 17 00:00:00 2001 From: pfg Date: Sat, 21 Feb 2015 15:02:27 +0000 Subject: Prevent NULL pointer de-reference. As a follow up to r279090, if dp hasn't been defined, we shouldn't attempt to do an optimization here. --- lib/libc/regex/engine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libc/regex') diff --git a/lib/libc/regex/engine.c b/lib/libc/regex/engine.c index 8fc67ce..436370d 100644 --- a/lib/libc/regex/engine.c +++ b/lib/libc/regex/engine.c @@ -244,7 +244,7 @@ matcher(struct re_guts *g, ZAPSTATE(&m->mbs); /* Adjust start according to moffset, to speed things up */ - if (g->moffset > -1) + if (dp != NULL && g->moffset > -1) start = ((dp - g->moffset) < start) ? start : dp - g->moffset; SP("mloop", m->st, *start); -- cgit v1.1