From bf242b0633e18934f490cdc093d251a11722ec31 Mon Sep 17 00:00:00 2001 From: Benjamin Smedberg Date: Fri, 6 Dec 2013 12:03:47 -0500 Subject: [PATCH] Bug 767343 - Use fallible allocation in nsSupportsString::SetData because people are putting arbitrarily-large data in it, perhaps session-restore data but I'm not sure, r=froydnj --HG-- extra : rebase_source : 2ca78473213f43537886e0108af6f88227278a72 --- xpcom/ds/nsSupportsPrimitives.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xpcom/ds/nsSupportsPrimitives.cpp b/xpcom/ds/nsSupportsPrimitives.cpp index fb6d61427fa8..d32672c7b491 100644 --- a/xpcom/ds/nsSupportsPrimitives.cpp +++ b/xpcom/ds/nsSupportsPrimitives.cpp @@ -98,7 +98,9 @@ NS_IMETHODIMP nsSupportsCStringImpl::ToString(char **_retval) NS_IMETHODIMP nsSupportsCStringImpl::SetData(const nsACString& aData) { - mData = aData; + bool ok = mData.Assign(aData, fallible_t()); + if (!ok) + return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -135,7 +137,9 @@ NS_IMETHODIMP nsSupportsStringImpl::ToString(PRUnichar **_retval) NS_IMETHODIMP nsSupportsStringImpl::SetData(const nsAString& aData) { - mData = aData; + bool ok = mData.Assign(aData, fallible_t()); + if (!ok) + return NS_ERROR_OUT_OF_MEMORY; return NS_OK; }