Skip to content

Commit

Permalink
Fix #11170, accessing empty env var on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
tkelman committed May 9, 2015
1 parent 403423c commit 2a86ef1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion base/env.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2a86ef1

Please sign in to comment.