Skip to content

Commit 928e47e

Browse files
dschoJunio C Hamano
authored andcommitted
Initialize lock_file struct to all zero.
hold_lock_file_for_update() relies on that. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 854b462 commit 928e47e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

builtin-update-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ int cmd_update_index(int argc, const char **argv, char **envp)
490490
git_config(git_default_config);
491491

492492
/* We can't free this memory, it becomes part of a linked list parsed atexit() */
493-
lock_file = xmalloc(sizeof(struct lock_file));
493+
lock_file = xcalloc(1, sizeof(struct lock_file));
494494

495495
newfd = hold_lock_file_for_update(lock_file, get_index_file());
496496
if (newfd < 0)

builtin-write-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ int write_tree(unsigned char *sha1, int missing_ok, const char *prefix)
1616
int entries, was_valid, newfd;
1717

1818
/* We can't free this memory, it becomes part of a linked list parsed atexit() */
19-
struct lock_file *lock_file = xmalloc(sizeof(struct lock_file));
19+
struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
2020

2121
newfd = hold_lock_file_for_update(lock_file, get_index_file());
2222

0 commit comments

Comments
 (0)