]> granicus.if.org Git - libass/commitdiff
fontselect: avoid undefined behavior
authorwm4 <wm4@nowhere>
Wed, 9 Sep 2015 10:06:47 +0000 (12:06 +0200)
committerwm4 <wm4@nowhere>
Wed, 9 Sep 2015 10:06:47 +0000 (12:06 +0200)
Passing NULL as argument to %s format specifiers when using the printf
fasmily of functions is not allowed. While some libcs handle it, other
libcs will simply crash.

libass/ass_fontselect.c

index 4818472028b75dc82b20fdb88f0876bf4d082c91..19ae6d4bdd1efae5f055299272e8ba3547760df7 100644 (file)
@@ -666,7 +666,8 @@ char *ass_font_select(ASS_FontSelector *priv, ASS_Library *library,
         if (res)
             ass_msg(library, MSGL_WARN, "fontselect: Using default "
                     "font family: (%s, %d, %d) -> %s, %d, %s",
-                    family, bold, italic, res, *index, *postscript_name);
+                    family, bold, italic, res, *index,
+                    *postscript_name ? *postscript_name : "(none)");
     }
 
     if (!res && default_provider && default_provider->funcs.get_fallback) {
@@ -688,13 +689,14 @@ char *ass_font_select(ASS_FontSelector *priv, ASS_Library *library,
         *index = priv->index_default;
         ass_msg(library, MSGL_WARN, "fontselect: Using default font: "
                 "(%s, %d, %d) -> %s, %d, %s", family, bold, italic,
-                priv->path_default, *index, *postscript_name);
+                priv->path_default, *index,
+                *postscript_name ? *postscript_name : "(none)");
     }
 
     if (res)
         ass_msg(library, MSGL_INFO,
                 "fontselect: (%s, %d, %d) -> %s, %d, %s", family, bold,
-                italic, res, *index, *postscript_name);
+                italic, res, *index, *postscript_name ? *postscript_name : "(none)");
 
     return res;
 }