summaryrefslogtreecommitdiffstats
path: root/libass
diff options
context:
space:
mode:
authoreugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-05-03 19:26:43 +0000
committereugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-05-03 19:26:43 +0000
commite3e99c086ce5908d2edc10658707f8cd2d956f3a (patch)
tree11fb94032e1b5972de0238a547a43f5196f61932 /libass
parent0b8bd90b9ef5b0038b85813b0c75549eb9c5d2a9 (diff)
downloadmpv-e3e99c086ce5908d2edc10658707f8cd2d956f3a.tar.bz2
mpv-e3e99c086ce5908d2edc10658707f8cd2d956f3a.tar.xz
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. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23230 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libass')
-rw-r--r--libass/ass_font.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/libass/ass_font.c b/libass/ass_font.c
index 57423d1dd7..7217f40825 100644
--- a/libass/ass_font.c
+++ b/libass/ass_font.c
@@ -83,12 +83,13 @@ ass_font_t* ass_font_new(ass_library_t* library, FT_Library ftlibrary, void* fc_
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 @@ ass_font_t* ass_font_new(ass_library_t* library, FT_Library ftlibrary, void* fc_
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);
}
/**