From: Mark Jamsek Subject: set a couple missed errors on fprintf(3) failure To: gameoftrees@openbsd.org Date: Tue, 03 Dec 2024 17:16:03 +1100 3/4: As per the subject, set the error object on fprintf(3) failure before jumping to done. commit 49e5ef007b04dcaf4503fe9bf4fb1b71ef7b75a9 from: Mark Jamsek date: Tue Dec 3 05:39:10 2024 UTC set a couple missed error objects on fprintf(3) failure M lib/diff.c | 6+ 2- 1 file changed, 6 insertions(+), 2 deletions(-) commit - e0ddd7157595c4170db368174b848adc889c937a commit + 49e5ef007b04dcaf4503fe9bf4fb1b71ef7b75a9 blob - 4d43433bd888ab680d73274f2cf8770252d1db47 blob + 7b0f22caf13f3bf87b053cad9bb208b1113649bb --- lib/diff.c +++ lib/diff.c @@ -219,8 +219,10 @@ diff_blobs(struct got_diff_line **lines, size_t *nline } n = fprintf(outfile, "blob - %s%s\n", idstr1, modestr1 ? modestr1 : ""); - if (n < 0) + if (n < 0) { + err = got_error_from_errno("fprintf"); goto done; + } outoff += n; if (lines && *lines) { err = add_line_metadata(lines, nlines, outoff, @@ -231,8 +233,10 @@ diff_blobs(struct got_diff_line **lines, size_t *nline n = fprintf(outfile, "blob + %s%s\n", idstr2, modestr2 ? modestr2 : ""); - if (n < 0) + if (n < 0) { + err = got_error_from_errno("fprintf"); goto done; + } outoff += n; if (lines && *lines) { err = add_line_metadata(lines, nlines, outoff, -- Mark Jamsek GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68