Bug 534136 part 4bis: Fix review comments from peterv that should have been in initial patch.
--- 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|.