bug fix, hash keys need to be malloced, this fixes a core dump

and allows 'make check' in backend/file to pass instead of croaking.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9202 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2003-09-01 15:13:49 +00:00
parent edbd6c43c9
commit 317d476377

View File

@ -227,7 +227,7 @@ qof_entity_lookup (QofEntityTable *entity_table,
return e_node->entity;
}
static GHashTable *
static inline GHashTable *
entity_get_types_table (QofEntityTable *entity_table, QofIdType entity_type)
{
GHashTable *ht;
@ -238,7 +238,11 @@ entity_get_types_table (QofEntityTable *entity_table, QofIdType entity_type)
ht = g_hash_table_new (id_hash, id_compare);
g_assert(ht);
g_hash_table_insert (entity_table->hash_of_types, (gpointer)entity_type, ht);
/* XXX should use string_cache instead of strdup */
/* Need strdup because values are sometimes freed */
/* this is a memory leak, since malloc'ed value is not freed */
g_hash_table_insert (entity_table->hash_of_types,
(gpointer)g_strdup(entity_type), ht);
return ht;
}