]> git.ipfire.org Git - thirdparty/git.git/commit
grep: fix leaking grep pattern
authorPatrick Steinhardt <ps@pks.im>
Thu, 26 Sep 2024 11:46:54 +0000 (13:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Sep 2024 15:25:36 +0000 (08:25 -0700)
commit6d82437a470fc7797e41f5a7ac4874914db7cdb8
tree466a9227d9b5d973b8552956bdc92b849fd40227
parentf8d2ca7246394535dff520aac6d1a66a5a807b75
grep: fix leaking grep pattern

When creating a pattern via `create_grep_pat()` we allocate the pattern
member of the structure regardless of the token type. But later, when we
try to free the structure, we free the pattern member conditionally on
the token type and thus leak memory.

Plug this leak. The leak is exposed by t7814, but plugging it alone does
not make the whole test suite pass.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
grep.c