mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 635546 - Calculate the string length correctly for REG_EXPAND_SZ values expanded through nsWindowsRegKey::ReadStringValue; r=bsmedberg,jimm a=blocking-betaN+
The buffer length returned from ExpandEnvironmentStringsW includes the terminatng null character, so we need to decrement it before setting the string length, as XPCOM strings need to be stored with correct length information.
This commit is contained in:
parent
0312a750a6
commit
d9b3b4ace6
@ -337,6 +337,8 @@ nsWindowsRegKey::ReadStringValue(const nsAString &name, nsAString &result)
|
||||
resultLen = ExpandEnvironmentStringsW(flatSource.get(), NULL, 0);
|
||||
if (resultLen > 0) {
|
||||
nsAutoString expandedResult;
|
||||
// |resultLen| includes the terminating null character
|
||||
--resultLen;
|
||||
expandedResult.SetLength(resultLen);
|
||||
nsAString::iterator begin;
|
||||
expandedResult.BeginWriting(begin);
|
||||
@ -345,11 +347,11 @@ nsWindowsRegKey::ReadStringValue(const nsAString &name, nsAString &result)
|
||||
|
||||
resultLen = ExpandEnvironmentStringsW(flatSource.get(),
|
||||
begin.get(),
|
||||
resultLen);
|
||||
resultLen + 1);
|
||||
if (resultLen <= 0) {
|
||||
rv = ERROR_UNKNOWN_FEATURE;
|
||||
result.Truncate();
|
||||
} else if (resultLen > 0) {
|
||||
} else {
|
||||
rv = ERROR_SUCCESS;
|
||||
result = expandedResult;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user