From cb49bbbbd4071c424c9e7f2b830b8bdbcd67ef76 Mon Sep 17 00:00:00 2001
From: Per Hedbor <ph@opera.com>
Date: Fri, 21 Feb 2014 16:02:30 +0100
Subject: [PATCH] Avoid crashing when indexing multiset containing only
 destructed objects

---
 src/multiset.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/multiset.c b/src/multiset.c
index 351662bdd6..44fc0c63ae 100644
--- a/src/multiset.c
+++ b/src/multiset.c
@@ -1429,7 +1429,7 @@ union msnode *low_multiset_find_eq (struct multiset *l, struct svalue *key)
       /* Try again with tracking to be able to remove the destructed node. */
       RBSTACK_INIT (rbstack);
 
-      while (1) {
+      while (msd->root) {
 	enum find_types find_type = low_multiset_track_eq (msd, key, &rbstack);
 
 	if (l->msd != msd)
@@ -1450,10 +1450,11 @@ union msnode *low_multiset_find_eq (struct multiset *l, struct svalue *key)
 	  goto done;
 	}
       }
-
-      /* NOT REACHED */
+      node = NULL;
+      RBSTACK_FREE (rbstack);
+      goto done;
     }
-  }
+  } /* while(1) */
 
 done:
   UNSET_ONERROR (uwp);
-- 
GitLab