fixed potential buffer overflow
authorkhizmax <khizmax@gmail.com>
Fri, 29 Jul 2016 15:51:05 +0000 (18:51 +0300)
committerkhizmax <khizmax@gmail.com>
Fri, 29 Jul 2016 15:51:05 +0000 (18:51 +0300)
cds/intrusive/mspriority_queue.h

index 41fd568..ba3db52 100644 (file)
@@ -291,7 +291,12 @@ namespace cds { namespace intrusive {
             }
 
             counter_type i = m_ItemCounter.inc();
-            assert( i < m_Heap.capacity() );
+            if ( i >= m_Heap.capacity() ) {
+                // the heap is full
+                m_Lock.unlock();
+                m_Stat.onPushFailed();
+                return false;
+            }
 
             node& refNode = m_Heap[i];
             refNode.lock();