# HG changeset patch # User Humm plumber: fix substrings in match rules Unmatched substrings are nil, so we can't rely on nil terminating the array of substrings. diff -r 5346858b7aef sys/src/cmd/plumb/match.c --- a/sys/src/cmd/plumb/match.c Tue Apr 13 13:28:31 2021 +0200 +++ b/sys/src/cmd/plumb/match.c Tue Apr 20 20:11:01 2021 +0200 @@ -36,12 +36,13 @@ 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