From 96d0a3f56c4427fdc5c52a4ee7dae540c6f2537e Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Sat, 11 Apr 2015 14:35:50 +1000 Subject: main-fn-win: fix handle validity check for XP Apparently the standard handles can be set to bogus values on XP. Use GetFileType to check whether they refer to an actual file/pipe/etc. The logic used by is_valid_handle() is now pretty similar to what the CRT uses to check for valid stdio handles. --- player/main-fn-win.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'player') diff --git a/player/main-fn-win.c b/player/main-fn-win.c index ad883dcba9..28fc5b3c24 100644 --- a/player/main-fn-win.c +++ b/player/main-fn-win.c @@ -14,7 +14,8 @@ int _dowildcard = 0; static bool is_valid_handle(HANDLE h) { - return h != INVALID_HANDLE_VALUE && h != NULL; + return h != INVALID_HANDLE_VALUE && h != NULL && + GetFileType(h) != FILE_TYPE_UNKNOWN; } static bool has_redirected_stdio(void) -- cgit v1.2.3