Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates-src > by-pkgid > 09236aad26217818763c178cc3a83744 > files > 18

ghostscript-9.24-1.5.mga6.src.rpm

From df4ec49e0f2237fe5b17d5d620f8c3cad95b3b5e Mon Sep 17 00:00:00 2001
From: Robin Watts <robin.watts@artifex.com>
Date: Wed, 5 Sep 2018 13:46:50 +0100
Subject: [PATCH] Second attempt at fix for bug 699699.

The previous attempt failed because it gave the wrong return value
when we hit an empty argument.

Now we ignore empty arguments.
---
 base/gsargs.c  | 11 +++++++++--
 psi/imainarg.c |  2 ++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/base/gsargs.c b/base/gsargs.c
index c1c1869..028529f 100644
--- a/base/gsargs.c
+++ b/base/gsargs.c
@@ -242,7 +242,14 @@ arg_next(arg_list * pal, const char **argstr, const gs_memory_t *errmem)
                 else if (pas->u.s.memory)
                     gs_free_object(pas->u.s.memory, pas->u.s.chars,
                                    "arg_next");
-                pal->depth--;
+                /* If depth is 0, then we are reading from the simple
+                 * argument list and we just hit an "empty" argument
+                 * (such as -o ""). Just ignore it and look for the next
+                 * one. If depth > 0, then we're reading from a response
+                 * file, and we can't have empty arguments - so we've
+                 * hit the end of the response file. Pop up one level. */
+                if (pal->depth > 0)
+                    pal->depth--;
                 continue; /* Next argument */
             }
     #define is_eol(c) (c == '\r' || c == '\n')
@@ -348,7 +355,7 @@ arg_next(arg_list * pal, const char **argstr, const gs_memory_t *errmem)
             *argstr = NULL; /* Empty the argument string so we don't return it. */
             continue; /* Loop back to parse the first arg from the file. */
         }
-    } while (**argstr == 0); /* Until we get a non-empty arg */
+    } while (*argstr == NULL || **argstr == 0); /* Until we get a non-empty arg */
 
     return 1;
 }
diff --git a/psi/imainarg.c b/psi/imainarg.c
index 869a7aa..9dbb70a 100644
--- a/psi/imainarg.c
+++ b/psi/imainarg.c
@@ -691,6 +691,8 @@ run_stdin:
                     code = arg_next(pal, (const char **)&adef, minst->heap);
                     if (code < 0)
                         return code;
+                    if (code == 0)
+                        return gs_error_undefinedfilename;
                 } else
                     adef = arg;
                 if ((code = gs_main_init1(minst)) < 0)
-- 
2.9.1