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:
Humm 2021-04-21 08:28:32 +02:00
parent 192c1fd73a
commit b2ef0ff49d

View file

@ -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