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
1 changed files with 7 additions and 6 deletions
|
@ -36,12 +36,13 @@ setvar(Resub rs[10], char *match[10])
|
|||
free(match[i]);
|
||||
match[i] = nil;
|
||||
}
|
||||
for(i=0; i<10 && rs[i].sp!=nil; i++){
|
||||
n = rs[i].ep-rs[i].sp;
|
||||
match[i] = emalloc(n+1);
|
||||
memmove(match[i], rs[i].sp, n);
|
||||
match[i][n] = '\0';
|
||||
}
|
||||
for(i=0; i<10; i++)
|
||||
if(rs[i].sp!=nil){
|
||||
n = rs[i].ep-rs[i].sp;
|
||||
match[i] = emalloc(n+1);
|
||||
memmove(match[i], rs[i].sp, n);
|
||||
match[i][n] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in a new issue