# HG changeset patch # User eugeni # Date 1178220403 0 # Node ID c932f521344d14dc42e6845de97a75f43f55e415 # Parent d9b4bfea1093445740162bc75b541bae606da543 In ass_font_new, allocate temporary ass_font_t on stack and return the pointer to cache-owned copy. This fixes leaked ass_font_t struct. Without this, font pointers obtained from ass_font_new() and ass_font_cache_find() were different, and bitmaps rendered with the first one could not be located in the cache later. diff -r d9b4bfea1093 -r c932f521344d libass/ass_font.c --- a/libass/ass_font.c Thu May 03 19:13:54 2007 +0000 +++ b/libass/ass_font.c Thu May 03 19:26:43 2007 +0000 @@ -83,12 +83,13 @@ int index; FT_Face face; int error; - ass_font_t* font; + ass_font_t* fontp; + ass_font_t font; int mem_idx; - font = ass_font_cache_find(desc); - if (font) - return font; + fontp = ass_font_cache_find(desc); + if (fontp) + return fontp; path = fontconfig_select(fc_priv, desc->family, desc->bold, desc->italic, &index); @@ -110,26 +111,23 @@ charmap_magic(face); - font = calloc(1, sizeof(ass_font_t)); - font->ftlibrary = ftlibrary; - font->faces[0] = face; - font->n_faces = 1; - font->desc.family = strdup(desc->family); - font->desc.bold = desc->bold; - font->desc.italic = desc->italic; + font.ftlibrary = ftlibrary; + font.faces[0] = face; + font.n_faces = 1; + font.desc.family = strdup(desc->family); + font.desc.bold = desc->bold; + font.desc.italic = desc->italic; - font->m.xx = font->m.yy = (FT_Fixed)0x10000L; - font->m.xy = font->m.yy = 0; - font->v.x = font->v.y = 0; - font->size = 0; + font.m.xx = font.m.yy = (FT_Fixed)0x10000L; + font.m.xy = font.m.yy = 0; + font.v.x = font.v.y = 0; + font.size = 0; #ifdef HAVE_FONTCONFIG - font->charset = FcCharSetCreate(); + font.charset = FcCharSetCreate(); #endif - ass_font_cache_add(font); - - return font; + return ass_font_cache_add(&font); } /**