diff --git a/mozilla/xpcom/glue/nsTArray.h b/mozilla/xpcom/glue/nsTArray.h index ed1a4685aeb..1e63cf2cbe1 100644 --- a/mozilla/xpcom/glue/nsTArray.h +++ b/mozilla/xpcom/glue/nsTArray.h @@ -473,7 +473,7 @@ class nsTArray : public nsTArray_base { template void RemoveElement(const Item& item, const Comparator& comp) { index_type i = IndexOf(item, 0, comp); - if (i >= 0) + if (i != NoIndex) RemoveElementAt(i); } diff --git a/mozilla/xpcom/tests/TestTArray.cpp b/mozilla/xpcom/tests/TestTArray.cpp index ee3869dec76..cb4c4a13266 100644 --- a/mozilla/xpcom/tests/TestTArray.cpp +++ b/mozilla/xpcom/tests/TestTArray.cpp @@ -121,6 +121,10 @@ static PRBool test_basic_array(ElementType *data, ary.AppendElements(nsnull, 0); ary.AppendElements(empty); + // See bug 324981 + ary.RemoveElement(extra); + ary.RemoveElement(extra); + return PR_TRUE; }