[librsvg] gitlab#160 - rsvg-convert: Fix error reporting when running from stdin



commit 33cb3d684c79367ffc10a151db41088da847f617
Author: Philip Withnall <withnall endlessm com>
Date:   Tue Jan 24 09:47:03 2017 +0000

    gitlab#160 - rsvg-convert: Fix error reporting when running from stdin
    
    When no input files are provided, args may be NULL, but n_args is set to
    1 by the code handling stdin. This can result in a dereference of
    args[0] when it isn’t set. Avoid that by setting args to a dummy array
    of ['stdin'].
    
    Coverity ID: 1388557
    
    https://gitlab.gnome.org/GNOME/librsvg/issues/160

 rsvg-convert.c | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/rsvg-convert.c b/rsvg-convert.c
index 9770f5c..a5504b6 100644
--- a/rsvg-convert.c
+++ b/rsvg-convert.c
@@ -217,8 +217,11 @@ main (int argc, char **argv)
             n_args++;
 
     if (n_args == 0) {
+        const gchar * const stdin_args[] = { "stdin", NULL };
         n_args = 1;
         using_stdin = TRUE;
+        g_strfreev (args);
+        args = g_strdupv ((gchar **) stdin_args);
     } else if (n_args > 1 && (!format || !(!strcmp (format, "ps") || !strcmp (format, "eps") || !strcmp 
(format, "pdf")))) {
         g_printerr (_("Multiple SVG files are only allowed for PDF and (E)PS output.\n"));
         exit (1);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]