{"thread":{"id":"46554","subject":"[PATCH] sha1_file: release delta_stack on error in unpack_entry()","startedAt":"2017-08-10T09:42:34Z","lastAt":"2017-08-10T09:42:34Z","messageCount":1,"participants":["René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"326023","messageId":"79879fc4-c0e4-219d-2ed9-683a23c78840@web.de","threadId":"46554","inReplyTo":null,"subject":"[PATCH] sha1_file: release delta_stack on error in unpack_entry()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2017-08-10T09:42:21Z","receivedAt":"2017-08-10T09:42:34Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"When unpack_entry() encounters a broken packed object, it returns early.\nIt adjusts the reference count of the pack window, but leaks the buffer\nfor a big delta stack in case the small automatic one was not enough.\nJump to the cleanup code at end instead, which takes care of that.\n\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\n sha1_file.c | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex b60ae15f70..b7bb38b445 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -2542,8 +2542,8 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,\n \t\t\t\terror(\"bad packed object CRC for %s\",\n \t\t\t\t      sha1_to_hex(sha1));\n \t\t\t\tmark_bad_packed_object(p, sha1);\n-\t\t\t\tunuse_pack(&w_curs);\n-\t\t\t\treturn NULL;\n+\t\t\t\tdata = NULL;\n+\t\t\t\tgoto out;\n \t\t\t}\n \t\t}\n \n@@ -2681,6 +2681,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,\n \tif (final_size)\n \t\t*final_size = size;\n \n+out:\n \tunuse_pack(&w_curs);\n \n \tif (delta_stack != small_delta_stack)\n-- \n2.14.0\n"}]}