Bug 534136 part 4bis: Fix review comments from peterv that should have been in initial patch.
authorJonas Sicking <jonas@sicking.cc>
Mon, 08 Mar 2010 08:03:55 -0800
changeset 39107 a5de049fc2fbaa5d96c4970cf4d4bfd9f964f384
parent 39106 1041bbdd97eaa407c794607933007defa7dca67f
child 39108 b68bc22b6a3d55261af2d3d5cc0b6a28bf811a12
push id12014
push usersicking@mozilla.com
push dateMon, 08 Mar 2010 16:06:16 +0000
treeherdermozilla-central@a5de049fc2fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs534136
milestone1.9.3a3pre
Bug 534136 part 4bis: Fix review comments from peterv that should have been in initial patch.
parser/html/nsHtml5Atom.cpp
xpcom/ds/nsAtomTable.cpp
--- a/parser/html/nsHtml5Atom.cpp
+++ b/parser/html/nsHtml5Atom.cpp
@@ -46,16 +46,21 @@ nsHtml5Atom::nsHtml5Atom(const nsAString
     mString = static_cast<PRUnichar*>(buf->Data());
   }
   else {
     buf = nsStringBuffer::Alloc((mLength + 1) * sizeof(PRUnichar));
     mString = static_cast<PRUnichar*>(buf->Data());
     CopyUnicodeTo(aString, 0, mString, mLength);
     mString[mLength] = PRUnichar(0);
   }
+
+  NS_ASSERTION(mString[mLength] == PRUnichar(0), "null terminated");
+  NS_ASSERTION(buf && buf->StorageSize() >= (mLength+1) * sizeof(PRUnichar),
+               "enough storage");
+  NS_ASSERTION(Equals(aString), "correct data");
 }
 
 nsHtml5Atom::~nsHtml5Atom()
 {
   nsStringBuffer::FromData(mString)->Release();
 }
 
 NS_IMETHODIMP_(nsrefcnt)
--- a/xpcom/ds/nsAtomTable.cpp
+++ b/xpcom/ds/nsAtomTable.cpp
@@ -264,17 +264,19 @@ AtomImpl::AtomImpl(nsStringBuffer* aStri
 {
   mLength = aLength;
   mString = static_cast<PRUnichar*>(aStringBuffer->Data());
   // Technically we could currently avoid doing this addref by instead making
   // the static atom buffers have an initial refcount of 2.
   aStringBuffer->AddRef();
 
   NS_ASSERTION(mString[mLength] == PRUnichar(0), "null terminated");
-  NS_ASSERTION(aStringBuffer && aStringBuffer->StorageSize() == (mLength+1) * 2, "correct storage");
+  NS_ASSERTION(aStringBuffer &&
+               aStringBuffer->StorageSize() == (mLength+1) * sizeof(PRUnichar),
+               "correct storage");
 }
 
 AtomImpl::~AtomImpl()
 {
   NS_PRECONDITION(gAtomTable.ops, "uninitialized atom hashtable");
   // Permanent atoms are removed from the hashtable at shutdown, and we
   // don't want to remove them twice.  See comment above in
   // |AtomTableClearEntry|.