mirror of
https://github.com/git/git.git
synced 2024-12-12 11:24:02 +08:00
055e57b7b2
Fix a memory leak in code added in5d7eeee2ac
(git-show: grok blobs, trees and tags, too, 2006-12-14). As we iterate over a "<revision>..." command-line and encounter ad OBJ_COMMIT we want to use our "struct rev_info", but with a "pending" array of one element: the one commit we're showing in the loop. To do this5d7eeee2ac
saved away a pointer to rev.pending.objects and rev.pending.nr for its iteration. We'd then clobber those (and alloc) when we needed to show an OBJ_COMMIT. We'd therefore leak the "rev.pending" we started out with, and only free the new "rev.pending" in the "OBJ_COMMIT" case arm as prepare_revision_walk() would draw it down. Let's fix this memory leak. Now when we encounter an OBJ_COMMIT we save away the "rev.pending" before clearing it. We then add a single commit to it, which our indirect invocation of prepare_revision_walk() will remove. After that we restore the "rev.pending". Our "rev.pending" will then get free'd by the release_revisions() added inf6bfea0ad0
(revisions API users: use release_revisions() in builtin/log.c, 2022-04-13) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
28 lines
727 B
Bash
Executable File
28 lines
727 B
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Copyright (c) 2010 Ævar Arnfjörð Bjarmason
|
|
#
|
|
|
|
test_description="The Git C functions aren't broken by setlocale(3)"
|
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
|
. ./lib-gettext.sh
|
|
|
|
test_expect_success 'git show a ISO-8859-1 commit under C locale' '
|
|
. "$TEST_DIRECTORY"/t3901/8859-1.txt &&
|
|
test_commit "iso-c-commit" iso-under-c &&
|
|
git show >out 2>err &&
|
|
test_must_be_empty err &&
|
|
grep -q "iso-c-commit" out
|
|
'
|
|
|
|
test_expect_success GETTEXT_LOCALE 'git show a ISO-8859-1 commit under a UTF-8 locale' '
|
|
. "$TEST_DIRECTORY"/t3901/8859-1.txt &&
|
|
test_commit "iso-utf8-commit" iso-under-utf8 &&
|
|
LANGUAGE=is LC_ALL="$is_IS_locale" git show >out 2>err &&
|
|
test_must_be_empty err &&
|
|
grep -q "iso-utf8-commit" out
|
|
'
|
|
|
|
test_done
|