From 0795af10e2441acc936551074e5cb76755557a43 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 8 Aug 2011 14:17:24 -0400 Subject: [PATCH] Fix the check when adding a new variable to the config parser, and NULL pointers in the ConfigParser. - was checking if it didn't exist instead of looking for a duplicate --- openbox/config_parser.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openbox/config_parser.c b/openbox/config_parser.c index 941216b3..887db07e 100644 --- a/openbox/config_parser.c +++ b/openbox/config_parser.c @@ -125,9 +125,9 @@ static ObConfigParserEntity* add(ObConfigParser *p, ObConfigParserEntity *e; g_return_val_if_fail(def != NULL, NULL); - g_return_val_if_fail(g_hash_table_lookup(p->entities, name) != NULL, NULL); + g_return_val_if_fail(g_hash_table_lookup(p->entities, name) == NULL, NULL); - e = g_slice_new(ObConfigParserEntity); + e = g_slice_new0(ObConfigParserEntity); e->name = g_strdup(name); e->cb = FALSE; e->u.v.value = def; @@ -251,9 +251,9 @@ void config_parser_callback(ObConfigParser *p, const gchar *name, { ObConfigParserEntity *e; - g_return_if_fail(g_hash_table_lookup(p->entities, name) != NULL); + g_return_if_fail(g_hash_table_lookup(p->entities, name) == NULL); - e = g_slice_new(ObConfigParserEntity); + e = g_slice_new0(ObConfigParserEntity); e->name = g_strdup(name); e->cb = TRUE; e->u.cb.func = cb; -- 2.34.1