commit 04cdf6acc3e2bb972d4948a12406ab5d348d4760 from: Stefan Sperling via: Thomas Adam date: Thu Jun 23 14:09:34 2022 UTC check for errors from fclose() in patch_file() commit - 25054c242b7401a2a20e3c8b87f0a7d61d568909 commit + 04cdf6acc3e2bb972d4948a12406ab5d348d4760 blob - 193f1d3e3cf6366ab7379ecac4d61e5aaabafeb5 blob + fb69531b2970591164a171b0a1d1a72f3c97c819 --- lib/patch.c +++ lib/patch.c @@ -543,8 +543,8 @@ patch_file(struct got_patch *p, const char *path, FILE err = copy(tmp, orig, copypos, -1); done: - if (orig != NULL) - fclose(orig); + if (orig != NULL && fclose(orig) == EOF && err == NULL) + err = got_error_from_errno("fclose"); return err; } @@ -684,8 +684,8 @@ done: free(template); if (tmppath != NULL) unlink(tmppath); - if (tmp != NULL) - fclose(tmp); + if (tmp != NULL && fclose(tmp) == EOF && err == NULL) + err = got_error_from_errno("fclose"); free(tmppath); free(oldpath); free(newpath);