Bug 969871 - Use fallible allocation for text hyphenation; r=jfkthame

It seems like the sizes for these data structures can be controlled from
Web content, and we are already prepared to deal with OOM conditions,
except that we are using infallible allocations by mistake.
This commit is contained in:
Ehsan Akhgari 2014-02-08 13:10:44 -05:00
parent ef4e513fd2
commit 9f20e412a4
3 changed files with 3 additions and 3 deletions

View File

@ -302,7 +302,7 @@ nsLineBreaker::FindHyphenationPoints(nsHyphenator *aHyphenator,
uint8_t *aBreakState)
{
nsDependentSubstring string(aTextStart, aTextLimit);
nsAutoTArray<bool,200> hyphens;
AutoFallibleTArray<bool,200> hyphens;
if (NS_SUCCEEDED(aHyphenator->Hyphenate(string, hyphens))) {
for (uint32_t i = 0; i + 1 < string.Length(); ++i) {
if (hyphens[i]) {

View File

@ -21,7 +21,7 @@ public:
bool IsValid();
nsresult Hyphenate(const nsAString& aText, nsTArray<bool>& aHyphens);
nsresult Hyphenate(const nsAString& aText, FallibleTArray<bool>& aHyphens);
private:
~nsHyphenator();

View File

@ -44,7 +44,7 @@ nsHyphenator::IsValid()
nsresult
nsHyphenator::Hyphenate(const nsAString& aString,
nsTArray<bool>& aHyphens)
FallibleTArray<bool>& aHyphens)
{
if (!aHyphens.SetLength(aString.Length())) {
return NS_ERROR_OUT_OF_MEMORY;