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:
Eric Rahm
2016-05-05 15:50:35 -07:00
parent 9febb0d924
commit 5a13a5db3e
3 changed files with 15 additions and 4 deletions

View File

@@ -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;
}