Bug 284219: add EnsureStringLength() helper function to nsReadableUtils.h to
authordveditz@cruzio.com
Thu, 28 Jun 2007 13:02:58 -0700
changeset 2934 28cbb9516328c15534d7829721a843442d4c4f08
parent 2933 a06bb370c9c9a1b8467e6db4e8a3f4549543c0ac
child 2935 d950c6cb0f30b9edb724132d9f030eefa4f9a205
push idunknown
push userunknown
push dateunknown
bugs284219
milestone1.9a6pre
Bug 284219: add EnsureStringLength() helper function to nsReadableUtils.h to simplify OOM checks when growing an nsAString. r/sr=darin
intl/unicharutil/util/nsBidiUtils.cpp
--- a/intl/unicharutil/util/nsBidiUtils.cpp
+++ b/intl/unicharutil/util/nsBidiUtils.cpp
@@ -272,16 +272,18 @@ static void ReverseString(PRUnichar* aBu
   }
 }
 
 nsresult ArabicShaping(const PRUnichar* aString, PRUint32 aLen,
                        PRUnichar* aBuf, PRUint32 *aBufLen, 
                        PRBool aInputLogical, PRBool aOutputLogical)
 {
   nsAutoString tempString(aString, aLen);
+  if (tempString.Length() != aLen)
+    return NS_ERROR_OUT_OF_MEMORY;
   PRUnichar *tempBuf = tempString.BeginWriting();
   if (aInputLogical) {
     ReverseString(tempBuf, aLen);
   }
   const PRUnichar* src = tempBuf;
   const PRUnichar* p;
   PRUnichar* dest = aBuf;
   PRUnichar formB;