summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Build/source/texk/dvipdfmx/ChangeLog4
-rw-r--r--Build/source/texk/dvipdfmx/dvipdfmx-20110311/src/dpxfile.c37
-rw-r--r--Build/source/texk/xdvipdfmx/ChangeLog.TL6
-rw-r--r--Build/source/texk/xdvipdfmx/src/dpxfile.c37
4 files changed, 43 insertions, 41 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;
}
diff --git a/Build/source/texk/xdvipdfmx/ChangeLog.TL b/Build/source/texk/xdvipdfmx/ChangeLog.TL
index 0ba93958a71..322a45c1318 100644
--- a/Build/source/texk/xdvipdfmx/ChangeLog.TL
+++ b/Build/source/texk/xdvipdfmx/ChangeLog.TL
@@ -1,7 +1,11 @@
ChangeLog.TL: TeX Live (TL) changes for xdvipdfmx
=================================================
-2011-06-03 Akira Kakuto <kakuto@fuk,kindai.ac.jp>
+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/xdvipdfmx/src/dpxfile.c b/Build/source/texk/xdvipdfmx/src/dpxfile.c
index c68fdce21aa..3f718ba1d31 100644
--- a/Build/source/texk/xdvipdfmx/src/dpxfile.c
+++ b/Build/source/texk/xdvipdfmx/src/dpxfile.c
@@ -157,9 +157,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;
@@ -168,19 +172,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++;
}
@@ -189,8 +190,7 @@ static int exec_spawn (char *cmd)
p++;
while (*p != '\'') {
if (*p == '\0') {
- free (cmdv);
- return -1;
+ goto done;
}
*pp++ = *p++;
}
@@ -201,8 +201,7 @@ static int exec_spawn (char *cmd)
p++;
while (*p != '\'') {
if (*p == '\0') {
- free (cmdv);
- return -1;
+ goto done;
}
*pp++ = *p++;
}
@@ -213,7 +212,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
@@ -229,7 +228,6 @@ static int exec_spawn (char *cmd)
p++;
qv++;
}
- *qv = NULL;
#ifdef WIN32
ret = spawnvp (_P_WAIT, *cmdv, (const char* const*) cmdv);
#else
@@ -238,7 +236,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);
@@ -247,14 +245,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;
}