From 88d43f79747fb649d730ade5f8c221573be0be7b Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Thu, 8 Oct 2009 23:55:23 +0200 Subject: 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. --- libass/ass_fontconfig.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libass') 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, -- cgit v1.2.3