mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
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:
parent
ef4e513fd2
commit
9f20e412a4
@ -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]) {
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user