check fprintf() return values in got_diff_objects_as_commits()
diff --git a/lib/diff.c b/lib/diff.c
index f3a09e4..2bfa94e 100644
--- a/lib/diff.c
+++ b/lib/diff.c
@@ -529,12 +529,25 @@ got_diff_objects_as_commits(struct got_object *obj1, struct got_object *obj2,
err = got_object_get_id_str(&id_str, obj2);
if (err)
goto done;
- fprintf(outfile, "commit: %s\n", id_str);
+ if (fprintf(outfile, "commit: %s\n", id_str) < 0) {
+ err = got_error_from_errno();
+ free(id_str);
+ goto done;
+ }
free(id_str);
- fprintf(outfile, "author: %s\n", commit2->author);
- if (strcmp(commit2->author, commit2->committer) != 0)
- fprintf(outfile, "committer: %s\n", commit2->committer);
- fprintf(outfile, "\n%s\n", commit2->logmsg);
+ if (fprintf(outfile, "author: %s\n", commit2->author) < 0) {
+ err = got_error_from_errno();
+ goto done;
+ }
+ if (strcmp(commit2->author, commit2->committer) != 0 &&
+ fprintf(outfile, "committer: %s\n", commit2->committer) < 0) {
+ err = got_error_from_errno();
+ goto done;
+ }
+ if (fprintf(outfile, "\n%s\n", commit2->logmsg) < 0) {
+ err = got_error_from_errno();
+ goto done;
+ }
err = got_diff_objects_as_trees(tree_obj1, tree_obj2, repo, outfile);
done: