stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject svn commit: r640522 - in /stdcxx/branches/4.2.x: include/rw/_tree.cc tests/regress/23.set.stdcxx-216.cpp
Date Mon, 24 Mar 2008 19:00:18 GMT
Author: vitek
Date: Mon Mar 24 12:00:16 2008
New Revision: 640522

URL: http://svn.apache.org/viewvc?rev=640522&view=rev
Log:

2008-03-24  Travis Vitek  <vitek@roguewave.com>

	Merged rev 639495 from trunk

	2008-03-20  Travis Vitek  <vitek@roguewave.com>

	* tests/regress/23.set.stdcxx-216.cpp: Add regression test for
	issue caused by fix to STDCXX-216.
	* include/rw/_tree.cc: (insert): Ensure tree is not empty before
	comparing keys to avoid uninitialized memory read.


Added:
    stdcxx/branches/4.2.x/tests/regress/23.set.stdcxx-216.cpp
      - copied unchanged from r639495, stdcxx/trunk/tests/regress/23.set.stdcxx-216.cpp
Modified:
    stdcxx/branches/4.2.x/include/rw/_tree.cc

Modified: stdcxx/branches/4.2.x/include/rw/_tree.cc
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/include/rw/_tree.cc?rev=640522&r1=640521&r2=640522&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/include/rw/_tree.cc (original)
+++ stdcxx/branches/4.2.x/include/rw/_tree.cc Mon Mar 24 12:00:16 2008
@@ -350,11 +350,15 @@
 
     const _C_link_t __hint = _ITER_NODE (__it);
 
-    // if __hint is the right most child and __key is greater,
-    // then insert on the right
+    // if __hint is the right most child, or tree is empty
     if (__hint == _C_end->_C_child [1]) {
-        if (_C_cmp (__hint->_C_key (), _KeyOf ()(__v)))
+
+        // if tree is not empty and __key is greater
+        // then insert on the right
+        if (_C_size && _C_cmp (__hint->_C_key (), _KeyOf ()(__v)))
             return _C_insert (0, __hint, __v);
+
+        // otherwise just insert
         return insert (__v, __dup).first;
     }
 
@@ -366,10 +370,10 @@
         return insert (__v, __dup).first;
     }
 
-    // if __hint is the leftmost child and __key is less
+    // if __hint is the left most child and __key is less
     // then insert on the left
     if (__hint == _C_end->_C_child [0]) {
-        if (size () && _C_cmp (_KeyOf ()(__v), __hint->_C_key ()))
+        if (_C_cmp (_KeyOf ()(__v), __hint->_C_key ()))
             return _C_insert (__hint, __hint, __v);
         return insert (__v, __dup).first;
     }



Mime
View raw message