summaryrefslogtreecommitdiff
path: root/src/diff_output.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2013-03-04 00:21:56 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2013-03-04 00:21:56 +0100
commit323bb88514347ebb7a1d760490384b305f4f4d92 (patch)
treee7529d3e16050b69af146479c66d70647290675e /src/diff_output.c
parentdce5f26f4d72b024891e70f6130e63389d9f181a (diff)
downloadlibgit2-323bb88514347ebb7a1d760490384b305f4f4d92.tar.gz
Fix a few leaks
`git_diff_get_patch()` would unconditionally load the patch object and then simply leak it if the user hadn't requested it. Short-circuit loading the object if the user doesn't want it. The rest of the plugs are simply calling the free functions of objects allocated during the tests.
Diffstat (limited to 'src/diff_output.c')
-rw-r--r--src/diff_output.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/diff_output.c b/src/diff_output.c
index 13434beb9..209a6e017 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -1509,6 +1509,10 @@ int git_diff_get_patch(
if (git_diff_delta__should_skip(ctxt.opts, delta))
return 0;
+ /* Don't load the patch if the user doesn't want it */
+ if (!patch_ptr)
+ return 0;
+
patch = diff_patch_alloc(&ctxt, delta);
if (!patch)
return -1;