]> git.ipfire.org Git - thirdparty/git.git/commit
xdiff: fix a memory leak
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Wed, 16 Feb 2022 10:15:06 +0000 (10:15 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 16 Feb 2022 18:58:05 +0000 (10:58 -0800)
commit9df0fc3d578acfdeb7fa1914fcf0507adb021fa5
treebf6cf359e110cdb44f4cf5fe048b29e540f7b5ba
parent2b9c1209706bc2ef0ab09fb0bdc7d405e225ce8b
xdiff: fix a memory leak

Although the patience and histogram algorithms initialize the
environment they do not free it if there is an error. In contrast for
the Myers algorithm the environment is initalized in xdl_do_diff() and
it is freed if there is an error. Fix this by always initializing the
environment in xdl_do_diff() and freeing it there if there is an
error. Remove the comment in do_patience_diff() about the environment
being freed by xdl_diff() as it is not accurate because (a) xdl_diff()
does not do that if there is an error and (b) xdl_diff() is not the
only caller.

Reported-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
xdiff/xdiffi.c
xdiff/xhistogram.c
xdiff/xpatience.c