diff --git a/parser/htmlparser/nsExpatDriver.cpp b/parser/htmlparser/nsExpatDriver.cpp
index 2e672f99c50..ac66f6a1916 100644
--- a/parser/htmlparser/nsExpatDriver.cpp
+++ b/parser/htmlparser/nsExpatDriver.cpp
@@ -33,6 +33,7 @@
#include "mozilla/Logging.h"
+using mozilla::fallible;
using mozilla::LogLevel;
#define kExpatSeparatorChar 0xFFFF
@@ -415,7 +416,9 @@ nsExpatDriver::HandleCharacterData(const char16_t *aValue,
NS_ASSERTION(mSink, "content sink not found!");
if (mInCData) {
- mCDataText.Append(aValue, aLength);
+ if (!mCDataText.Append(aValue, aLength, fallible)) {
+ MaybeStopParser(NS_ERROR_OUT_OF_MEMORY);
+ }
}
else if (mSink) {
nsresult rv = mSink->HandleCharacterData(aValue, aLength);