Author: fireball Date: Wed Apr 24 22:56:43 2013 New Revision: 58848 URL: http://svn.reactos.org/svn/reactos?rev=58848&view=rev Log: [RTL] - Do not set result variable NodeOrParent in RtlpFindGenericTableNodeOrParent in case the generic table is empty, just returning TableEmptyTree is enough. - Fix improper enumeration of generic tables nodes. The way they were done previously clearly shows that noone was actually testing these APIs and a simple mistake (do/while instead of while loop) led to a NULL pointer access. Thanks to Pierre for developing MCB tests which revealed this problem. Rephrasing Vladimir Lenin: "Test, test and again test!"
Modified: trunk/reactos/lib/rtl/generictable.c Modified: trunk/reactos/lib/rtl/generictable.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/generictable.c?rev=58848&r1=58847&r2=58848&view=diff ============================================================================== --- trunk/reactos/lib/rtl/generictable.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/generictable.c [iso-8859-1] Wed Apr 24 22:56:43 2013 @@ -34,7 +34,6 @@ /* Quick check to see if the table is empty */ if (RtlIsGenericTableEmpty(Table)) { - *NodeOrParent = NULL; return TableEmptyTree; } @@ -338,11 +337,11 @@ { /* Then find the leftmost element */ FoundNode = Table->TableRoot; - do + while(RtlLeftChild(FoundNode)) { /* Get the left child */ FoundNode = RtlLeftChild(FoundNode); - } while(RtlLeftChild(FoundNode)); + } /* Splay it */ _Analysis_assume_(FoundNode != NULL); @@ -377,11 +376,11 @@ { /* Then find the leftmost element */ FoundNode = Table->TableRoot; - do + while(RtlLeftChild(FoundNode)) { /* Get the left child */ FoundNode = RtlLeftChild(FoundNode); - } while(RtlLeftChild(FoundNode)); + } /* Splay it */ *RestartKey = FoundNode;