diff --git a/xpcom/glue/nsTArray.cpp b/xpcom/glue/nsTArray.cpp index dae9e5299a2..5aaccd0c924 100644 --- a/xpcom/glue/nsTArray.cpp +++ b/xpcom/glue/nsTArray.cpp @@ -82,11 +82,7 @@ nsTArray_base::EnsureCapacity(size_type capacity, size_type elemSize) { } // Use doubling algorithm when forced to increase available capacity. - NS_ASSERTION(mHdr->mCapacity > 0, "should not have buffer of zero size"); - size_type temp = mHdr->mCapacity; - while (temp < capacity) - temp <<= 1; - capacity = temp; + capacity = PR_MAX(capacity, mHdr->mCapacity << 1); Header *header; if (UsesAutoArrayBuffer()) {