From: Erik Faye-Lund Date: Thu, 23 Sep 2010 17:35:25 +0000 (+0000) Subject: mingw: do not crash on open(NULL, ...) X-Git-Tag: v1.7.4-rc0~193^2~3 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1a4042096c2e8893246a99ef8e43c07acb76f54b;p=git.git 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 Signed-off-by: Erik Faye-Lund Signed-off-by: Pat Thoyts --- diff --git a/compat/mingw.c b/compat/mingw.c index 431e32265..bd1403a1d 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -127,7 +127,7 @@ int mingw_open (const char *filename, int oflags, ...) mode = va_arg(args, int); va_end(args); - if (!strcmp(filename, "/dev/null")) + if (filename && !strcmp(filename, "/dev/null")) filename = "nul"; fd = open(filename, oflags, mode); @@ -160,7 +160,7 @@ ssize_t mingw_write(int fd, const void *buf, size_t count) #undef fopen FILE *mingw_fopen (const char *filename, const char *otype) { - if (!strcmp(filename, "/dev/null")) + if (filename && !strcmp(filename, "/dev/null")) filename = "nul"; return fopen(filename, otype); }