From f3069e3ea515c62fe2b952cfb64b0d4a4beedca7 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Thu, 9 Apr 2015 05:13:43 -0700 Subject: [PATCH] text-freetype2: Prevent potential null dereference --- plugins/text-freetype2/find-font.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/text-freetype2/find-font.c b/plugins/text-freetype2/find-font.c index 9c415a8a9..969fbfa59 100644 --- a/plugins/text-freetype2/find-font.c +++ b/plugins/text-freetype2/find-font.c @@ -156,14 +156,16 @@ const char *get_font_path(const char *family, uint16_t size, const char *style, bool bold = !!(flags & OBS_FONT_BOLD); bool italic = !!(flags & OBS_FONT_ITALIC); - if (!family) + if (!family || !*family) return NULL; - dstr_copy(&style_str, style); - dstr_replace(&style_str, "Bold", ""); - dstr_replace(&style_str, "Italic", ""); - dstr_replace(&style_str, " ", " "); - dstr_depad(&style_str); + if (style) { + dstr_copy(&style_str, style); + dstr_replace(&style_str, "Bold", ""); + dstr_replace(&style_str, "Italic", ""); + dstr_replace(&style_str, " ", " "); + dstr_depad(&style_str); + } dstr_copy(&face_and_style, family); if (!dstr_is_empty(&style_str)) {