зеркало из https://github.com/microsoft/git.git
builtin/apply: free patch when parse_chunk() fails
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>
This commit is contained in:
Родитель
484e776158
Коммит
7a6a44c2dc
|
@ -4371,8 +4371,10 @@ static int apply_patch(int fd, const char *filename, int options)
|
||||||
patch->inaccurate_eof = !!(options & INACCURATE_EOF);
|
patch->inaccurate_eof = !!(options & INACCURATE_EOF);
|
||||||
patch->recount = !!(options & RECOUNT);
|
patch->recount = !!(options & RECOUNT);
|
||||||
nr = parse_chunk(buf.buf + offset, buf.len - offset, patch);
|
nr = parse_chunk(buf.buf + offset, buf.len - offset, patch);
|
||||||
if (nr < 0)
|
if (nr < 0) {
|
||||||
|
free_patch(patch);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if (apply_in_reverse)
|
if (apply_in_reverse)
|
||||||
reverse_patches(patch);
|
reverse_patches(patch);
|
||||||
if (use_patch(patch)) {
|
if (use_patch(patch)) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче