AUDIT: r17747 - gnucash/trunk/src/register/register-gnome - Bug #563273: Fix crash on startup

Christian Stimming cstim at cvs.gnucash.org
Sat Dec 6 16:33:15 EST 2008


Author: cstim
Date: 2008-12-06 16:33:14 -0500 (Sat, 06 Dec 2008)
New Revision: 17747
Trac: http://svn.gnucash.org/trac/changeset/17747

Modified:
   gnucash/trunk/src/register/register-gnome/gnucash-sheet.c
   gnucash/trunk/src/register/register-gnome/gnucash-style.c
Log:
Bug #563273: Fix crash on startup

Here's the problem... GnuCash uses a hash table with int keys to store
dimensions, and the key value is the number of rows in the dimension being
stored.  The problem is that this key value is stored in a static int inside
the style_get_key function, which means that the key always has the same
address, and the hash functions in glib2 store the *address*, not the *value*
of the key.  Unfortunately, the hash algorithm changed some time between
glib2-2.18.2 and glib2-2.19.2, such that there's a hash conflict between the
key value 1 and the key value 2, but since the value of the already hashed key
was swiped out from under it when style_get_key "created" a new key, the hash
table entry that's already there matches even when it shouldn't have.

The attached patch cleans this up by allocating memory to hold the key when
inserting it into the hash table.  It also changes the way the hash table is
created to ensure that the memory is freed when a hash table entry or hash
table is destroyed.  And while I was at it, I made the same fix for the cursors
hash table, which was also leaking memory when entries were removed or the
table was destroyed.

Patch by Jonathan Kamens.
BP



More information about the gnucash-patches mailing list