summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHumm <hummsmith42@gmail.com>2021-04-21 08:28:32 +0200
committerHumm <hummsmith42@gmail.com>2021-04-21 08:28:32 +0200
commitb2ef0ff49de457a6e48751e7eedd8131cdca5f98 (patch)
tree224851465a3cdb07cb679c6282178fc2aec10abd
parent192c1fd73a54870f8736908886d7fe0905e5ec58 (diff)
downloadplan9front-b2ef0ff49de457a6e48751e7eedd8131cdca5f98.tar.xz
plumber: fix substrings in match rules
Unmatched substrings are nil, so we can't rely on nil terminating the array of substrings.
-rw-r--r--sys/src/cmd/plumb/match.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/src/cmd/plumb/match.c b/sys/src/cmd/plumb/match.c
index 22fb36b16..3a00c16b7 100644
--- a/sys/src/cmd/plumb/match.c
+++ b/sys/src/cmd/plumb/match.c
@@ -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