Skip to content

Commit

Permalink
Fix memory issue when dpulicate entry in map file
Browse files Browse the repository at this point in the history
The insertion of a map entry was mishandled when there is a
duplicate entry. The library routine actually takes care of
the situation by itself.
  • Loading branch information
tony-vanderpeet authored and carlgsmith committed Feb 13, 2024
1 parent 0106abb commit d54028a
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions alfred.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,23 +657,9 @@ sch_load_namespace_mappings (alfred_instance instance, const char *filename)
ns_names = g_strsplit (buf, " ", 2);
if (ns_names[0] && ns_names[1])
{
void *old_key;
void *old_value;

/* Look up this node name to check for duplicates. */
if (g_hash_table_lookup_extended (instance->map_hash_table, ns_names[0],
&old_key, &old_value))
{
g_hash_table_insert (instance->map_hash_table, g_strdup (ns_names[0]),
g_strdup (ns_names[1]));
g_free (old_key);
g_free (old_value);
}
else
{
g_hash_table_insert (instance->map_hash_table, g_strdup (ns_names[0]),
g_strdup (ns_names[1]));
}
/* Insert will take care of duplicates automatically. */
g_hash_table_insert (instance->map_hash_table, g_strdup (ns_names[0]),
g_strdup (ns_names[1]));
}
g_strfreev (ns_names);
}
Expand Down

0 comments on commit d54028a

Please sign in to comment.