ref: 702402cf9bec0e2d19228976ca003f6c04f23e19
parent: 1da71bf1449f2c6b2dfddae868223303276f8071
author: Michael Forney <mforney@mforney.org>
date: Mon Oct 3 01:51:24 EDT 2022
patch: fix uninitialized Fbuf during dry run
--- a/sys/src/cmd/patch.c
+++ b/sys/src/cmd/patch.c
@@ -568,10 +568,11 @@
for(i = 0; i < p->nhunk; i++){
h = &p->hunk[i];
if(curfile == nil || strcmp(curfile, h->newpath) != 0){
- if(!dryrun)
+ if(!dryrun){
slurp(&f, h->oldpath);
+ e = f.buf;
+ }
curfile = h->newpath;
- e = f.buf;
}
if(!dryrun){
s = e;
@@ -581,7 +582,8 @@
e += h->oldlen;
}
if(i+1 == p->nhunk || strcmp(curfile, p->hunk[i+1].newpath) != 0){
- o = append(o, &osz, e, f.buf + f.len);
+ if(!dryrun)
+ o = append(o, &osz, e, f.buf + f.len);
blat(h->oldpath, h->newpath, o, osz);
osz = 0;
}
--
⑨