summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2020-06-15 14:26:13 +0200
committerPatrick Steinhardt <ps@pks.im>2020-06-17 07:34:10 +0200
commit490d0c9ceab25b57006b96cd3a4a3cbb95350c7b (patch)
tree6b17d6bdb255fe11b65d41041c1179a80f64f810
parentbea5fd9f44857ddae2addd543ac5cf444c1280ff (diff)
downloadlibgit2-490d0c9ceab25b57006b96cd3a4a3cbb95350c7b.tar.gz
diff_print: return out-of-memory situation when printing binary
We currently don't check for out-of-memory situations on exiting `format_binary` and, as a result, may return a partially filled buffer. Fix this by checking the buffer via `git_buf_oom`.
-rw-r--r--src/diff_print.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/diff_print.c b/src/diff_print.c
index afe2efae1..1ef0f1d83 100644
--- a/src/diff_print.c
+++ b/src/diff_print.c
@@ -491,6 +491,9 @@ static int format_binary(
}
git_buf_putc(pi->buf, '\n');
+ if (git_buf_oom(pi->buf))
+ return -1;
+
return 0;
}