summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-02-13 00:42:29 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-02-13 00:42:29 -0800
commitf8dbae3bf1f9c559f4c0b896af249c63a3c0d7a5 (patch)
tree27cdc10815b98cc27e71e50d77a1983f35a87758
parent71e8f9979fcc7586137e5162e054539aadfdef2f (diff)
downloadtxr-f8dbae3bf1f9c559f4c0b896af249c63a3c0d7a5.tar.gz
txr-f8dbae3bf1f9c559f4c0b896af249c63a3c0d7a5.tar.bz2
txr-f8dbae3bf1f9c559f4c0b896af249c63a3c0d7a5.zip
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).
-rw-r--r--hash.c8
1 files 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)));
}
}