mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1270310
- Part 1: Make allocation in ConvertStringLineBreaks fallible. r=froydnj, r=smaug
ConvertStringLineBreaks calls ConvertUnicharLineBreaksInSitu which uses fallible allocation. We should make the potential allocation in |BeginWriting| fallible as well and handle the failure. This also updates the callers to |ConvertStringLineBreaks| to handle the error properly in release builds.
This commit is contained in:
parent
a00c07b27f
commit
f5b4b3b7b8
@ -6315,12 +6315,17 @@ HTMLInputElement::SaveState()
|
||||
inputState = new HTMLInputElementState();
|
||||
nsAutoString value;
|
||||
GetValue(value);
|
||||
DebugOnly<nsresult> rv =
|
||||
nsresult rv =
|
||||
nsLinebreakConverter::ConvertStringLineBreaks(
|
||||
value,
|
||||
nsLinebreakConverter::eLinebreakPlatform,
|
||||
nsLinebreakConverter::eLinebreakContent);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Converting linebreaks failed!");
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Converting linebreaks failed!");
|
||||
return rv;
|
||||
}
|
||||
|
||||
inputState->SetValue(value);
|
||||
break;
|
||||
}
|
||||
|
@ -1085,7 +1085,11 @@ HTMLTextAreaElement::SaveState()
|
||||
value,
|
||||
nsLinebreakConverter::eLinebreakPlatform,
|
||||
nsLinebreakConverter::eLinebreakContent);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Converting linebreaks failed!");
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Converting linebreaks failed!");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsString> pState =
|
||||
do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID);
|
||||
|
@ -464,7 +464,9 @@ nsLinebreakConverter::ConvertStringLineBreaks(nsString& aIoString,
|
||||
// remember the old buffer in case
|
||||
// we blow it away later
|
||||
nsString::char_iterator stringBuf;
|
||||
aIoString.BeginWriting(stringBuf);
|
||||
if (!aIoString.BeginWriting(stringBuf, fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
int32_t newLen;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user