From 8f1867a19f7ca881a32878dcee08ddce11b5db36 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Mon, 3 Oct 2022 05:51:24 +0000 Subject: patch: fix uninitialized Fbuf during dry run --- sys/src/cmd/patch.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sys/src/cmd/patch.c') diff --git a/sys/src/cmd/patch.c b/sys/src/cmd/patch.c index 7b25285cb..def9f05ca 100644 --- a/sys/src/cmd/patch.c +++ b/sys/src/cmd/patch.c @@ -568,10 +568,11 @@ apply(Patch *p, char *fname) 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 @@ apply(Patch *p, char *fname) 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; } -- cgit v1.2.3