From 46086177e205989a652b6b0d69a2a1b29c8830d2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Wed, 24 Feb 2016 12:42:32 +0100
Subject: [PATCH] Multiset.Iterator: Fixed potential NULL-dereference.

Fixes [CID 742519].
---
 src/iterators.cmod | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/iterators.cmod b/src/iterators.cmod
index ef290dcb8f..d2e34ae9c0 100644
--- a/src/iterators.cmod
+++ b/src/iterators.cmod
@@ -666,8 +666,9 @@ PIKECLASS multiset_iterator
     {
       struct object *o = low_clone (multiset_iterator_program);
       struct multiset_iterator_struct *copy = OBJ2_MULTISET_ITERATOR (o);
-      if ((copy->l = li->l))
-	add_ref(li->l);
+      if (!(copy->l = li->l))
+	return o;
+      add_ref(copy->l);
       if ((copy->nodepos = li->nodepos) >= 0) add_msnode_ref (copy->l);
       if ((copy->lock_index = li->lock_index)) {
 	add_ref (copy->l->msd);
-- 
GitLab