Skip to content

Commit

Permalink
Fix JuliaLang#11170, accessing empty env var on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
tkelman committed Jun 6, 2015
1 parent 0856285 commit 14414f9
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 14414f9

Please sign in to comment.