From 5cb7b80bc96c4dd7929a8d9ce299af875085a7d2 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 13 Feb 2019 00:42:29 -0800 Subject: hash-uni: bugfix. * hash.c (hash_uni): The join function must only be called for the values of keys that exist in both hashes. The broken logic here unconditionally calls the join function for all keys in the left hash (using nil as the right join value when the key doesn't exist in the right hash). --- hash.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hash.c b/hash.c index 0b1f05a3..4242fd58 100644 --- a/hash.c +++ b/hash.c @@ -1380,8 +1380,12 @@ val hash_uni(val hash1, val hash2, val join_func) if (missingp(join_func)) { sethash(hout, car(entry), cdr(entry)); } else { - loc ptr = gethash_l(self, hout, car(entry), nulloc); - set(ptr, funcall2(join_func, cdr(entry), deref(ptr))); + val new_p; + loc ptr = gethash_l(self, hout, car(entry), mkcloc(new_p)); + if (new_p) + sethash(hout, car(entry), cdr(entry)); + else + set(ptr, funcall2(join_func, cdr(entry), deref(ptr))); } } -- cgit v1.2.3