summaryrefslogtreecommitdiff
path: root/diffcore.h
diff options
context:
space:
mode:
authorLibravatar Jared Hance <jaredhance@gmail.com>2012-03-07 17:21:25 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-03-07 14:56:08 -0800
commit6fe53908f954b5683ca08d3745be1d76dd665483 (patch)
treeecfb79acdac0385a6464d1c0ef9bcb314e4638bb /diffcore.h
parentMerge branch 'maint-1.7.7' into maint-1.7.8 (diff)
downloadtgif-6fe53908f954b5683ca08d3745be1d76dd665483.tar.xz
apply: do not leak patches and fragments
In the while loop inside apply_patch, patch and fragments are dynamically allocated with a calloc. However, only unused patches are actually freed and the rest are left to leak. Since a list is actively built up consisting of the used patches, they can simply be iterated and freed at the end of the function. In addition, the text in fragments were not freed, primarily because they mostly point into a patch text that is freed as a whole. But there are some cases where new piece of memory is allocated and pointed by a fragment (namely, when handling a binary patch). Introduce a free_patch bitfield to mark each fragment if its text needs to be freed, and free patches, fragments and fragment text that need to be freed when we are done with the input. Signed-off-by: Jared Hance <jaredhance@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diffcore.h')
0 files changed, 0 insertions, 0 deletions