Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
builtin/apply: free patch when parse_chunk() fails
author
Christian Couder
<christian.couder@gmail.com>
Wed, 16 Mar 2016 19:35:11 +0000
(20:35 +0100)
committer
Junio C Hamano
<gitster@pobox.com>
Fri, 1 Apr 2016 17:21:55 +0000
(10:21 -0700)
When parse_chunk() fails it can return -1, for example
when find_header() doesn't find a patch header.
In this case it's better in apply_patch() to free the
"struct patch" that we just allocated instead of
leaking it.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/apply.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
484e776
)
diff --git
a/builtin/apply.c
b/builtin/apply.c
index dbdfa9b646f5891628e15278bf559a2397769754..ce3b77853c7a409b40d14400172327978266f9ca 100644
(file)
--- a/
builtin/apply.c
+++ b/
builtin/apply.c
@@
-4371,8
+4371,10
@@
static int apply_patch(int fd, const char *filename, int options)
patch->inaccurate_eof = !!(options & INACCURATE_EOF);
patch->recount = !!(options & RECOUNT);
nr = parse_chunk(buf.buf + offset, buf.len - offset, patch);
- if (nr < 0)
+ if (nr < 0) {
+ free_patch(patch);
break;
+ }
if (apply_in_reverse)
reverse_patches(patch);
if (use_patch(patch)) {