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]); 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