diff options
author | wm4 <wm4@nowhere> | 2014-11-09 10:41:54 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-11-09 10:41:54 +0100 |
commit | 11300cd37fc0038f3004b0da5748091f5f763738 (patch) | |
tree | 243fa115af89216ee2a4463edcef440c488f7448 /libass/ass_fontconfig.c | |
parent | dc054a1fdb1e9145e905612f296bbafd5ba7b530 (diff) | |
download | libass-11300cd37fc0038f3004b0da5748091f5f763738.tar.bz2 libass-11300cd37fc0038f3004b0da5748091f5f763738.tar.xz |
Check more mallocs
This is just a start and gets most easy ones.
Diffstat (limited to 'libass/ass_fontconfig.c')
-rw-r--r-- | libass/ass_fontconfig.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/libass/ass_fontconfig.c b/libass/ass_fontconfig.c index dcb0bcf9..fc564cc4 100644 --- a/libass/ass_fontconfig.c +++ b/libass/ass_fontconfig.c @@ -160,6 +160,8 @@ static char *select_font(ASS_Library *library, FCInstance *priv, family_cnt = 1; { char *s = strdup(family); + if (!s) + goto error; char *p = s + strlen(s); while (--p > s) if (*p == ' ' || *p == '-') { @@ -246,6 +248,8 @@ static char *select_font(ASS_Library *library, FCInstance *priv, if (result != FcResultMatch) goto error; retval = strdup((const char *) r_file); + if (!retval) + goto error; result = FcPatternGetString(rpat, FC_FAMILY, 0, &r_family); if (result != FcResultMatch) @@ -344,9 +348,10 @@ char *fontconfig_select(ASS_Library *library, FCInstance *priv, if (!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, - res, *index); + if (res) + ass_msg(library, MSGL_WARN, "fontconfig_select: Using default font: " + "(%s, %d, %d) -> %s, %d", family, bold, italic, + res, *index); } if (!res) { res = select_font(library, priv, "Arial", 0, bold, italic, @@ -444,6 +449,9 @@ FCInstance *fontconfig_init(ASS_Library *library, const char *dir = library->fonts_dir; int i; + if (!priv) + return NULL; + if (!fc) { ass_msg(library, MSGL_WARN, "Fontconfig disabled, only default font will be used."); @@ -518,6 +526,8 @@ FCInstance *fontconfig_init(ASS_Library *library, "Fontconfig disabled, only default font will be used."); priv = calloc(1, sizeof(FCInstance)); + if (!priv) + return NULL; priv->path_default = path ? strdup(path) : 0; priv->index_default = 0; |