mirror of
git://git.proxmox.com/git/spiceterm.git
synced 2025-08-31 18:28:14 +00:00
fix memory leaks when using g_hashtable
when generating a bitmap for a character whose codepoint was above 255, we used a cache_id of 0, malloc'd a CachedImage and inserted it into a g_hashtable, without freeing the one which was before inserted with cache_id 0 this is circumvented by only generating a CachedImage when having a cache_id != 0 the second leak was also with inserting into a hashtable, but there we give the hashtable the g_free method as a value_destroy_func Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
committed by
Wolfgang Bumiller
parent
377a4ee926
commit
ffeedb040b
4
input.c
4
input.c
@@ -837,8 +837,8 @@ spiceterm_create(uint32_t width, uint32_t height, SpiceTermOptions *opts)
|
|||||||
SpiceCoreInterface *core = basic_event_loop_init();
|
SpiceCoreInterface *core = basic_event_loop_init();
|
||||||
SpiceScreen *spice_screen = spice_screen_new(core, width, height, opts);
|
SpiceScreen *spice_screen = spice_screen_new(core, width, height, opts);
|
||||||
|
|
||||||
keymap = g_hash_table_new(g_int_hash, g_int_equal);
|
keymap = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, g_free);
|
||||||
|
|
||||||
if (!parse_keymap(opts->keymap ? opts->keymap : "en-us")) {
|
if (!parse_keymap(opts->keymap ? opts->keymap : "en-us")) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
11
screen.c
11
screen.c
@@ -297,10 +297,13 @@ spice_screen_draw_char_cmd(SpiceScreen *spice_screen, int x, int y, int c,
|
|||||||
dst += 4;
|
dst += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ce = g_new(CachedImage, 1);
|
|
||||||
ce->cache_id = cache_id;
|
if (cache_id != 0) {
|
||||||
ce->bitmap = bitmap;
|
ce = g_new(CachedImage, 1);
|
||||||
g_hash_table_insert(spice_screen->image_cache, &ce->cache_id, ce);
|
ce->cache_id = cache_id;
|
||||||
|
ce->bitmap = bitmap;
|
||||||
|
g_hash_table_insert(spice_screen->image_cache, &ce->cache_id, ce);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bbox.left = left; bbox.top = top;
|
bbox.left = left; bbox.top = top;
|
||||||
|
Reference in New Issue
Block a user