зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1000079 - Don't let Windows overwrite length 0 strings. r=bsmedberg
This commit is contained in:
Родитель
715b91be72
Коммит
02f9fb48d5
|
@ -931,8 +931,8 @@ GetRegWindowsAppDataFolder(bool aLocal, nsAString& _retval)
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
// |size| includes room for the terminating null character
|
||||
DWORD resultLen = size / 2 - 1;
|
||||
// |size| may or may not include room for the terminating null character
|
||||
DWORD resultLen = size / 2;
|
||||
|
||||
_retval.SetLength(resultLen);
|
||||
nsAString::iterator begin;
|
||||
|
@ -951,6 +951,11 @@ GetRegWindowsAppDataFolder(bool aLocal, nsAString& _retval)
|
|||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if (!_retval.CharAt(resultLen - 1)) {
|
||||
// It was already null terminated.
|
||||
_retval.Truncate(resultLen - 1);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче