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
diff --git a/src/libgit2/diff_print.c b/src/libgit2/diff_print.c
index 03d25b0..a910362 100644
--- a/src/libgit2/diff_print.c
+++ b/src/libgit2/diff_print.c
@@ -316,6 +316,12 @@ static int diff_print_oid_range(
static int diff_delta_format_path(
git_str *out, const char *prefix, const char *filename)
{
+ if (!filename)
+ {
+ /* don't prefix "/dev/null" */
+ return git_str_puts(out, "/dev/null");
+ }
+
if (git_str_joinpath(out, prefix, filename) < 0)
return -1;