diff options
author | Grigori Goronzy <greg@blackbox> | 2009-10-08 23:55:23 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2009-10-08 23:55:23 +0200 |
commit | 88d43f79747fb649d730ade5f8c221573be0be7b (patch) | |
tree | 1dcc13e5b810eab467b2e31ae7d9e6897b26ddc4 /libass | |
parent | 29b5f2cc548a9c68a4855c6c85ac38aa25561f25 (diff) | |
download | libass-88d43f79747fb649d730ade5f8c221573be0be7b.tar.bz2 libass-88d43f79747fb649d730ade5f8c221573be0be7b.tar.xz |
strdup() fontconfig strings freed by caller
fontconfig_select() can return the path to the default font as fallback,
but the caller frees it later. Return a copy with strdup() instead.
Diffstat (limited to 'libass')
-rw-r--r-- | libass/ass_fontconfig.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libass/ass_fontconfig.c b/libass/ass_fontconfig.c index 006be97..15bc5c7 100644 --- a/libass/ass_fontconfig.c +++ b/libass/ass_fontconfig.c @@ -250,7 +250,8 @@ char *fontconfig_select(ASS_Library *library, FCInstance *priv, char *res = 0; if (!priv->config) { *index = priv->index_default; - return priv->path_default; + res = priv->path_default ? strdup(priv->path_default) : 0; + return res; } if (family && *family) res = @@ -266,7 +267,7 @@ char *fontconfig_select(ASS_Library *library, FCInstance *priv, family, bold, italic, res, *index); } if (!res && priv->path_default) { - res = priv->path_default; + res = strdup(priv->path_default); *index = priv->index_default; ass_msg(library, MSGL_WARN, "fontconfig_select: Using default font: " "(%s, %d, %d) -> %s, %d", family, bold, italic, @@ -534,7 +535,8 @@ char *fontconfig_select(ASS_Library *library, FCInstance *priv, uint32_t code) { *index = priv->index_default; - return priv->path_default; + char* res = priv->path_default ? strdup(priv->path_default) : 0; + return res; } FCInstance *fontconfig_init(ASS_Library *library, |