Skip to content

Commit d427f95

Browse files
committed
diff_delta_format_path: handle null filename
This fixes a crash in test cases test_diff_parse__new_file_with_space_and_regenerate_patch and test_diff_parse__delete_file_with_space_and_regenerate_patch
1 parent 1186632 commit d427f95

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libgit2/diff_print.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,12 @@ static int diff_print_oid_range(
316316
static int diff_delta_format_path(
317317
git_str *out, const char *prefix, const char *filename)
318318
{
319+
if (!filename)
320+
{
321+
/* don't prefix "/dev/null" */
322+
return git_str_puts(out, "/dev/null");
323+
}
324+
319325
if (git_str_joinpath(out, prefix, filename) < 0)
320326
return -1;
321327

0 commit comments

Comments
 (0)