Skip to content

Commit 0662f0d

Browse files
pks-tgitster
authored andcommitted
builtin/fast-import: plug trivial memory leaks
Plug some trivial memory leaks in git-fast-import(1). Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 187b623 commit 0662f0d

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

builtin/fast-import.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ static unsigned int object_entry_alloc = 5000;
206206
static struct object_entry_pool *blocks;
207207
static struct hashmap object_table;
208208
static struct mark_set *marks;
209-
static const char *export_marks_file;
210-
static const char *import_marks_file;
209+
static char *export_marks_file;
210+
static char *import_marks_file;
211211
static int import_marks_file_from_stream;
212212
static int import_marks_file_ignore_missing;
213213
static int import_marks_file_done;
@@ -3274,6 +3274,7 @@ static void option_import_marks(const char *marks,
32743274
read_marks();
32753275
}
32763276

3277+
free(import_marks_file);
32773278
import_marks_file = make_fast_import_path(marks);
32783279
import_marks_file_from_stream = from_stream;
32793280
import_marks_file_ignore_missing = ignore_missing;
@@ -3316,6 +3317,7 @@ static void option_active_branches(const char *branches)
33163317

33173318
static void option_export_marks(const char *marks)
33183319
{
3320+
free(export_marks_file);
33193321
export_marks_file = make_fast_import_path(marks);
33203322
}
33213323

@@ -3357,6 +3359,8 @@ static void option_rewrite_submodules(const char *arg, struct string_list *list)
33573359
free(f);
33583360

33593361
string_list_insert(list, s)->util = ms;
3362+
3363+
free(s);
33603364
}
33613365

33623366
static int parse_one_option(const char *option)

t/t9300-fast-import.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ test_description='test git fast-import utility'
77
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
88
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
99

10+
TEST_PASSES_SANITIZE_LEAK=true
1011
. ./test-lib.sh
1112
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
1213

t/t9304-fast-import-marks.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22

33
test_description='test exotic situations with marks'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
test_expect_success 'setup dump of basic history' '

0 commit comments

Comments
 (0)