config: fix check for environment string expansion

If ExpandEnvironmentStringsW is successful, it returns the amount of
characters written, including the NUL terminator.

Thanks to Emeric for reading the MSDN documentation correctly.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
This commit is contained in:
Carlos Martín Nieto 2011-09-30 15:43:58 +02:00
parent 550c9f31bb
commit 358a15fd65

View File

@ -352,7 +352,7 @@ static int win32_find_system(char *system_config_path)
return GIT_ENOMEM; return GIT_ENOMEM;
ret = ExpandEnvironmentStringsW(query, apphome_utf16, size); ret = ExpandEnvironmentStringsW(query, apphome_utf16, size);
if (ret == 0 || ret >= size) if (ret != size)
return git__throw(GIT_ERROR, "Failed to expand environment strings"); return git__throw(GIT_ERROR, "Failed to expand environment strings");
if (_waccess(apphome_utf16, F_OK) < 0) { if (_waccess(apphome_utf16, F_OK) < 0) {