Reviewed by Darin Adler.
[WebKit-https.git] / JavaScriptCore / wtf / Deque.h
index 01bf40c64b3813c66237594a164f5d66e3054d7d..f8cf4fedbbc0e1ff85b59190f6b264640905a062 100644 (file)
@@ -369,10 +369,12 @@ namespace WTF {
         if (m_start) {
             if (m_end + 1 != m_start)
                 return;
-        } else {
-            if (m_end && m_end != m_buffer.capacity() - 1)
+        } else if (m_end) {
+            if (m_end != m_buffer.capacity() - 1)
                 return;
-        }
+        } else if (m_buffer.capacity())
+            return;
+
         expandCapacity();
     }
 
@@ -412,12 +414,14 @@ namespace WTF {
     template<typename T> template<typename U>
     inline void Deque<T>::prepend(const U& value)
     {
+        checkValidity();
         expandCapacityIfNeeded();
         if (!m_start)
             m_start = m_buffer.capacity() - 1;
         else
             --m_start;
         new (&m_buffer.buffer()[m_start]) T(value);
+        checkValidity();
     }
 
     template<typename T>