From 0b386157a1c9b3ffddb0caee8a3fb5eecd5b415a Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Wed, 17 Jun 2020 08:00:49 +0800 Subject: [PATCH] [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. --- bindings/guile/business-core.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/guile/business-core.scm b/bindings/guile/business-core.scm index 30c56d73e5..abaec8ce51 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))))))