ref: de667359ee6afab02bbd40996f94665e40c3bfea
parent: be557abec53c8585b26b10c6775ca542b1f8ee99
author: Humm <hummsmith42@gmail.com>
date: Wed Apr 21 04:28:32 EDT 2021
plumber: fix substrings in match rules Unmatched substrings are nil, so we can't rely on nil terminating the array of substrings.
--- a/sys/src/cmd/plumb/match.c
+++ b/sys/src/cmd/plumb/match.c
@@ -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
--
⑨