From 2a86ef11d74fcd744ab576179030ed4e223da1e1 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Fri, 8 May 2015 21:13:58 -0700 Subject: [PATCH] Fix #11170, accessing empty env var on Windows --- base/env.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/env.jl b/base/env.jl index ecd213adf718d..c82cd267ecbce 100644 --- a/base/env.jl +++ b/base/env.jl @@ -31,7 +31,7 @@ _hasenv(s::AbstractString) = _getenvlen(s)!=0 || GetLastError()!=ERROR_ENVVAR_NO function _jl_win_getenv(s::UTF16String,len::UInt32) val=zeros(UInt16,len) ret=ccall(:GetEnvironmentVariableW,stdcall,UInt32,(Cwstring,Ptr{UInt16},UInt32),s,val,len) - if ret==0 || ret != len-1 || val[end] != 0 + if (ret == 0 && len != 1) || ret != len-1 || val[end] != 0 error(string("getenv: ", s, ' ', len, "-1 != ", ret, ": ", FormatMessage())) end val