diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-06-03 15:39:31 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-06-03 15:39:31 +0000 |
commit | e4a9abe6cd6191aa7d0cbad1fdfa500d1acc3916 (patch) | |
tree | 7f83ccd0da6f811c112da922f0edeaf6a3a5f41f /Build/source/texk/dvipdfmx | |
parent | 9504a39c86d5c48fffaccb12c8325de5c50eb453 (diff) |
(x)dvipdfmx: Fix more bugs in exec_spawn()
git-svn-id: svn://tug.org/texlive/trunk@22764 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipdfmx')
-rw-r--r-- | Build/source/texk/dvipdfmx/ChangeLog | 4 | ||||
-rw-r--r-- | Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dpxfile.c | 37 |
2 files changed, 21 insertions, 20 deletions
diff --git a/Build/source/texk/dvipdfmx/ChangeLog b/Build/source/texk/dvipdfmx/ChangeLog index 48e5bc3f654..72070a25acd 100644 --- a/Build/source/texk/dvipdfmx/ChangeLog +++ b/Build/source/texk/dvipdfmx/ChangeLog @@ -1,3 +1,7 @@ +2011-06-03 Peter Breitenlohner <peb@mppmu.mpg.de> + + * dpxfile.c (exec_spawn): Exit if execvp() fails, some clean up. + 2011-06-03 Akira Kakuto <kakuto@fuk.kindai.ac.jp> * dpxfile.c: fix a bug in exec_spawn(). diff --git a/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dpxfile.c b/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dpxfile.c index 16c81eaf503..dbbf077989c 100644 --- a/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dpxfile.c +++ b/Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dpxfile.c @@ -155,9 +155,13 @@ static int exec_spawn (char *cmd) char **cmdv, **qv; char *p, *pp; char buf[1024]; - int i, ret; + int i, ret = -1; - if (!cmd || !*cmd) + if (!cmd) + return -1; + while (*cmd == ' ' || *cmd == '\t') + cmd++; + if (*cmd == '\0') return -1; i = 0; p = cmd; @@ -166,19 +170,16 @@ static int exec_spawn (char *cmd) i++; p++; } - cmdv = (char **) xmalloc (sizeof (char *) * (i+2)); + cmdv = xcalloc (i + 2, sizeof (char *)); p = cmd; qv = cmdv; - while (*p == ' ' || *p == '\t') - p++; while (*p) { pp = buf; if (*p == '"') { p++; while (*p != '"') { if (*p == '\0') { - free (cmdv); - return -1; + goto done; } *pp++ = *p++; } @@ -187,8 +188,7 @@ static int exec_spawn (char *cmd) p++; while (*p != '\'') { if (*p == '\0') { - free (cmdv); - return -1; + goto done; } *pp++ = *p++; } @@ -199,8 +199,7 @@ static int exec_spawn (char *cmd) p++; while (*p != '\'') { if (*p == '\0') { - free (cmdv); - return -1; + goto done; } *pp++ = *p++; } @@ -211,7 +210,7 @@ static int exec_spawn (char *cmd) } } *pp = '\0'; - if ((pp = strchr (buf, ' ')) || (pp = strchr (buf, '\t'))) { + if (strchr (buf, ' ') || strchr (buf, '\t')) { #ifdef WIN32 *qv = concat3 ("\"", buf, "\""); #else @@ -227,7 +226,6 @@ static int exec_spawn (char *cmd) p++; qv++; } - *qv = NULL; #ifdef WIN32 ret = spawnvp (_P_WAIT, *cmdv, (const char* const*) cmdv); #else @@ -236,7 +234,7 @@ static int exec_spawn (char *cmd) ret = -1; else if (i == 0) { if (execvp (*cmdv, cmdv)) - ret = -1; + _exit (-1); } else { if (wait (&ret) == i) { ret = (WIFEXITED (ret) ? WEXITSTATUS (ret) : -1); @@ -245,14 +243,13 @@ static int exec_spawn (char *cmd) } } #endif +done: qv = cmdv; - if (qv) { - while (*qv) { - free (*qv); - qv++; - } - free (cmdv); + while (*qv) { + free (*qv); + qv++; } + free (cmdv); return ret; } |