Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory issue when duplicate entry in map file #31

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading