diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/patch.c | 7 |
2 files changed, 9 insertions, 3 deletions
@@ -1,3 +1,8 @@ +2011-02-15 Andreas Gruenbacher <agruen@linbit.com> + + * src/patch.c (main): Fix use of initialized outst and add an + additional assert. Reported by Jim Meyering. + 2011-02-03 Ozan Çağlayan <ozan@pardus.org.tr> Create directory test case diff --git a/src/patch.c b/src/patch.c index 77be499..723a6e2 100644 --- a/src/patch.c +++ b/src/patch.c @@ -238,6 +238,7 @@ main (int argc, char **argv) } } + outst.st_size = -1; outfd = make_tempfile (&TMPOUTNAME, 'o', outname, O_WRONLY | binary_transput, instat.st_mode); TMPOUTNAME_needs_removal = 1; @@ -248,10 +249,9 @@ main (int argc, char **argv) outstate.ofp); if (! dry_run && ! outfile && ! skip_rest_of_patch) { - struct stat statbuf; - if (fstat (outfd, &statbuf) != 0) + if (fstat (outfd, &outst) != 0) pfatal ("%s", TMPOUTNAME); - outstate.zero_output = statbuf.st_size == 0; + outstate.zero_output = outst.st_size == 0; } close (outfd); outfd = -1; @@ -500,6 +500,7 @@ main (int argc, char **argv) set_file_attributes (TMPOUTNAME, attr, inname, &instat, mode, &new_time); + assert (outst.st_size != -1); move_file (TMPOUTNAME, &TMPOUTNAME_needs_removal, &outst, outname, mode, backup); |