Skip to content

Commit 1a40420

Browse files
kusmapatthoyts
authored andcommitted
mingw: do not crash on open(NULL, ...)
fetch_and_setup_pack_index() apparently pass a NULL-pointer to parse_pack_index(), which in turn pass it to check_packed_git_idx(), which again pass it to open(). Since open() already sets errno correctly for the NULL-case, let's just avoid the problematic strcmp. [PT: squashed in fix for fopen which was missed first time round] Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
1 parent 5e9677c commit 1a40420

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compat/mingw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ int mingw_open (const char *filename, int oflags, ...)
127127
mode = va_arg(args, int);
128128
va_end(args);
129129

130-
if (!strcmp(filename, "/dev/null"))
130+
if (filename && !strcmp(filename, "/dev/null"))
131131
filename = "nul";
132132

133133
fd = open(filename, oflags, mode);
@@ -160,7 +160,7 @@ ssize_t mingw_write(int fd, const void *buf, size_t count)
160160
#undef fopen
161161
FILE *mingw_fopen (const char *filename, const char *otype)
162162
{
163-
if (!strcmp(filename, "/dev/null"))
163+
if (filename && !strcmp(filename, "/dev/null"))
164164
filename = "nul";
165165
return fopen(filename, otype);
166166
}

0 commit comments

Comments
 (0)