Bug 1270310 - Part 1: Make allocation in ConvertStringLineBreaks fallible. r=froydnj, r=peterv

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 8f1e858810
commit c35b24cc51
3 changed files with 15 additions and 5 deletions

View File

@@ -5764,13 +5764,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!");
inputState->SetValue(value);
if (NS_FAILED(rv)) {
NS_ERROR("Converting linebreaks failed!");
return rv;
}
break;
}