Fix read-after-free in VG_(HT_destruct).  This fixes
memcheck/tests/mempools.  Thanks to Jeroen Witmond for tracking it
down.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5429 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_hashtable.c b/coregrind/m_hashtable.c
index 98d0413..eec3c31 100644
--- a/coregrind/m_hashtable.c
+++ b/coregrind/m_hashtable.c
@@ -234,11 +234,12 @@
 
 void VG_(HT_destruct)(VgHashTable table)
 {
-   UInt      i;
-   VgHashNode* node;
+   UInt       i;
+   VgHashNode *node, *node_next;
    
    for (i = 0; i < table->n_chains; i++) {
-      for (node = table->chains[i]; node != NULL; node = node->next) {
+      for (node = table->chains[i]; node != NULL; node = node_next) {
+         node_next = node->next;
          VG_(free)(node);
       }
    }