aboutsummaryrefslogtreecommitdiff
path: root/src/libregexp
diff options
context:
space:
mode:
authorDavid du Colombier <0intro@gmail.com>2015-08-09 21:18:41 +0200
committerRuss Cox <rsc@swtch.com>2016-11-02 23:17:40 +0000
commit1b68dbef7b7dd7c4aa2b5755c1399cf66d2ea6fa (patch)
tree9bdfe9b3ff93d26c11c4b8731ed8927fdd942895 /src/libregexp
parent2d82ef9d98aeae7592e9e4036722468a1dc53acb (diff)
downloadplan9port-1b68dbef7b7dd7c4aa2b5755c1399cf66d2ea6fa.tar.gz
plan9port-1b68dbef7b7dd7c4aa2b5755c1399cf66d2ea6fa.tar.bz2
plan9port-1b68dbef7b7dd7c4aa2b5755c1399cf66d2ea6fa.zip
libregexp: various fixes
- Check before dereference. - Fix memory leak - Remove duplicate if statement. - Remove trailing spaces. Change-Id: I140a05c8f7006493dddae753aebfa5b4577c65ef Reviewed-on: https://plan9port-review.googlesource.com/1301 Reviewed-by: Neven Sajko <nsajko@gmail.com> Reviewed-by: Russ Cox <rsc@swtch.com>
Diffstat (limited to 'src/libregexp')
-rw-r--r--src/libregexp/regexec.c2
-rw-r--r--src/libregexp/rregexec.c1
-rw-r--r--src/libregexp/rregsub.c7
3 files changed, 4 insertions, 6 deletions
diff --git a/src/libregexp/regexec.c b/src/libregexp/regexec.c
index a00fbcbc..b75f17fa 100644
--- a/src/libregexp/regexec.c
+++ b/src/libregexp/regexec.c
@@ -171,7 +171,7 @@ regexec2(Reprog *progp, /* program to run */
return -1;
relist1 = malloc(BIGLISTSIZE*sizeof(Relist));
if(relist1 == nil){
- free(relist1);
+ free(relist0);
return -1;
}
j->relist[0] = relist0;
diff --git a/src/libregexp/rregexec.c b/src/libregexp/rregexec.c
index c3a1753b..ca48a31d 100644
--- a/src/libregexp/rregexec.c
+++ b/src/libregexp/rregexec.c
@@ -40,7 +40,6 @@ rregexec1(Reprog *progp, /* program to run */
/* Execute machine once for each character, including terminal NUL */
s = j->rstarts;
do{
-
/* fast check for first char */
if(checkstart) {
switch(j->starttype) {
diff --git a/src/libregexp/rregsub.c b/src/libregexp/rregsub.c
index 5a4a564d..8b3e9738 100644
--- a/src/libregexp/rregsub.c
+++ b/src/libregexp/rregsub.c
@@ -27,7 +27,7 @@ rregsub(Rune *sp, /* source string */
case '8':
case '9':
i = *sp-'0';
- if(mp[i].s.rsp != 0 && mp!=0 && ms>i)
+ if(mp!=0 && mp[i].s.rsp != 0 && ms>i)
for(ssp = mp[i].s.rsp;
ssp < mp[i].e.rep;
ssp++)
@@ -46,9 +46,8 @@ rregsub(Rune *sp, /* source string */
*dp++ = *sp;
break;
}
- }else if(*sp == '&'){
- if(mp[0].s.rsp != 0 && mp!=0 && ms>0)
- if(mp[0].s.rsp != 0)
+ }else if(*sp == '&'){
+ if(mp!=0 && mp[0].s.rsp != 0 && ms>0)
for(ssp = mp[0].s.rsp;
ssp < mp[0].e.rep; ssp++)
if(dp < ep)