diff options
author | Grigori Goronzy <greg@blackbox> | 2009-06-27 15:20:28 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2009-06-27 16:31:36 +0200 |
commit | 2b4a7365b172bb0b5ee093329a7acdf6bce1cb8d (patch) | |
tree | a68c9be22946a0b58c5ceb0e9b084082242937d1 /libass/ass_render.c | |
parent | 490865d2c263aea6b7ee1dc1f197bb9fa7cb9b46 (diff) | |
download | libass-2b4a7365b172bb0b5ee093329a7acdf6bce1cb8d.tar.bz2 libass-2b4a7365b172bb0b5ee093329a7acdf6bce1cb8d.tar.xz |
Fix memory leak in render_overlap
render_overlap allocated memory for its hashmap key and values on the
heap, relying on the cache cleanup to free them. However, these
pointers are not directly inserted into the cache, but memcpy()'ed in
hashmap_insert, leading to a pretty bad memory leak.
Allocate the key and value on the stack instead to fix this problem.
Diffstat (limited to 'libass/ass_render.c')
-rw-r--r-- | libass/ass_render.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c index 6662e513..451c1d71 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -465,7 +465,7 @@ render_overlap(ass_renderer_t *render_priv, ass_image_t **last_tail, char m; composite_hash_key_t hk; composite_hash_val_t *hv; - composite_hash_key_t *nhk; + composite_hash_val_t chv; int ax = (*last_tail)->dst_x; int ay = (*last_tail)->dst_y; int aw = (*last_tail)->w; @@ -536,12 +536,9 @@ render_overlap(ass_renderer_t *render_priv, ass_image_t **last_tail, } // Insert bitmaps into the cache - nhk = calloc(1, sizeof(*nhk)); - memcpy(nhk, &hk, sizeof(*nhk)); - hv = calloc(1, sizeof(*hv)); - hv->a = (*last_tail)->bitmap; - hv->b = (*tail)->bitmap; - cache_add_composite(render_priv->cache.composite_cache, nhk, hv); + chv.a = (*last_tail)->bitmap; + chv.b = (*tail)->bitmap; + cache_add_composite(render_priv->cache.composite_cache, &hk, &chv); } /** |