Windows: avoid uv_guess_handle crash in when fd < 0

Happens only when using a debug version of the crt.
This commit is contained in:
Bert Belder 2012-03-08 16:43:56 +01:00
parent 1ac71a31e9
commit f43f1a7016

View File

@ -27,9 +27,15 @@
uv_handle_type uv_guess_handle(uv_file file) {
HANDLE handle = (HANDLE) _get_osfhandle(file);
HANDLE handle;
DWORD mode;
if (file < 0) {
return UV_UNKNOWN_HANDLE;
}
handle = (HANDLE) _get_osfhandle(file);
switch (GetFileType(handle)) {
case FILE_TYPE_CHAR:
if (GetConsoleMode(handle, &mode)) {