plumber: fix substrings in match rules
Unmatched substrings are nil, so we can't rely on nil terminating the array of substrings.
This commit is contained in:
parent
192c1fd73a
commit
b2ef0ff49d
|
@ -36,12 +36,13 @@ setvar(Resub rs[10], char *match[10])
|
||||||
free(match[i]);
|
free(match[i]);
|
||||||
match[i] = nil;
|
match[i] = nil;
|
||||||
}
|
}
|
||||||
for(i=0; i<10 && rs[i].sp!=nil; i++){
|
for(i=0; i<10; i++)
|
||||||
n = rs[i].ep-rs[i].sp;
|
if(rs[i].sp!=nil){
|
||||||
match[i] = emalloc(n+1);
|
n = rs[i].ep-rs[i].sp;
|
||||||
memmove(match[i], rs[i].sp, n);
|
match[i] = emalloc(n+1);
|
||||||
match[i][n] = '\0';
|
memmove(match[i], rs[i].sp, n);
|
||||||
}
|
match[i][n] = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in a new issue