commit 4f801be05521d52e3e5a43b3ed4b4a1206ed871e from: Igor Burago via: Dan Cross date: Wed Sep 07 13:30:40 2022 UTC plumber: set match variables past the first non-matching subexpression Fixes #563. commit - 28e91cd8798fd55993e98c83e577dd1d82955257 commit + 4f801be05521d52e3e5a43b3ed4b4a1206ed871e blob - 13ebe768f7d1b89469e1be562fd1cc9d0428aeed blob + 4cb32cc650c8ae501fdc1c9e688effcd0bf1f446 --- src/cmd/plumb/match.c +++ src/cmd/plumb/match.c @@ -45,12 +45,12 @@ setvar(Resub rs[10], char *match[10]) for(i=0; i<10; i++){ free(match[i]); match[i] = nil; - } - for(i=0; i<10 && rs[i].s.sp!=nil; i++){ - n = rs[i].e.ep-rs[i].s.sp; - match[i] = emalloc(n+1); - memmove(match[i], rs[i].s.sp, n); - match[i][n] = '\0'; + if(rs[i].s.sp != nil){ + n = rs[i].e.ep-rs[i].s.sp; + match[i] = emalloc(n+1); + memmove(match[i], rs[i].s.sp, n); + match[i][n] = '\0'; + } } }