Skip to content

Commit 8528445

Browse files
mhaggergitster
authored andcommitted
notes_merge_commit(): do not pass temporary buffer to other function
It is unsafe to pass a temporary buffer as an argument to read_directory(). Signed-off-by: Michael Haggerty <[email protected]> Acked-by: Johan Herland <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6320526 commit 8528445

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

notes-merge.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ int notes_merge_commit(struct notes_merge_options *o,
680680
* Finally store the new commit object SHA1 into 'result_sha1'.
681681
*/
682682
struct dir_struct dir;
683-
const char *path = git_path(NOTES_MERGE_WORKTREE "/");
683+
char *path = xstrdup(git_path(NOTES_MERGE_WORKTREE "/"));
684684
int path_len = strlen(path), i;
685685
const char *msg = strstr(partial_commit->buffer, "\n\n");
686686

@@ -720,6 +720,7 @@ int notes_merge_commit(struct notes_merge_options *o,
720720
result_sha1);
721721
OUTPUT(o, 4, "Finalized notes merge commit: %s",
722722
sha1_to_hex(result_sha1));
723+
free(path);
723724
return 0;
724725
}
725726

0 commit comments

Comments
 (0)