gnucash master: [business-core] string-hash doesn't not guarantee unique hash
Christopher Lam
clam at code.gnucash.org
Tue Jun 16 20:09:44 EDT 2020
Updated via https://github.com/Gnucash/gnucash/commit/0b386157 (commit)
from https://github.com/Gnucash/gnucash/commit/6071202c (commit)
commit 0b386157a1c9b3ffddb0caee8a3fb5eecd5b415a
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Wed Jun 17 08:00:49 2020 +0800
[business-core] string-hash doesn't not guarantee unique hash
subtle bug here-- used string-hash to convert guid-string to a number
which is faster to use as hash key. but string-hash does not guarantee
that there are no hash collisions. it is best to use guid string
instead which is guaranteed to uniquely define a split.
diff --git a/bindings/guile/business-core.scm b/bindings/guile/business-core.scm
index 30c56d73e..abaec8ce5 100644
--- a/bindings/guile/business-core.scm
+++ b/bindings/guile/business-core.scm
@@ -129,7 +129,7 @@
((not split)
(hash-for-each (lambda (k v) (gncOwnerFree v)) ht)
(hash-clear! ht))
- ((hashv-ref ht (string-hash (gncSplitGetGUID split))) => identity)
+ ((hash-ref ht (gncSplitGetGUID split)) => identity)
(else
(let ((lot (xaccSplitGetLot split))
(owner (gncOwnerNew)))
@@ -138,5 +138,5 @@
(gncInvoiceGetOwner
(gncInvoiceGetInvoiceFromLot lot)))
owner))
- (hashv-set! ht (string-hash (gncSplitGetGUID split)) owner)
+ (hash-set! ht (gncSplitGetGUID split) owner)
owner))))))
Summary of changes:
bindings/guile/business-core.scm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
More information about the gnucash-changes
mailing list