mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 02:57:38 +00:00
Bug 1000079 - Don't let Windows overwrite length 0 strings. r=bsmedberg
This commit is contained in:
parent
715b91be72
commit
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user