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 41fd568908005e13dcc2e44ba3e3070d3d4f513c..ba3db521c1215e9c124ce53b75347d39b84375ec 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();