Skip to content

Commit

Permalink
LuaTeX: Fix bugs in "os.spawn" second argument (thanks to tex@maxcher…
Browse files Browse the repository at this point in the history
…noff.ca)

git-svn-id: svn://tug.org/texlive/trunk/Build/source@73874 c570f23f-e606-0410-a88d-b1316a301751
  • Loading branch information
luigiScarso committed Feb 11, 2025
1 parent 4f0f7e8 commit 56bef69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions texk/web2c/luatexdir/lua/loslibext.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ static char **do_flatten_command(lua_State * L, char **runcmd)
*runcmd = NULL;

for (j = 1;; j++) {
lua_rawgeti(L, -1, j);
lua_rawgeti(L, 1, j);
if (lua_isnil(L, -1)) {
lua_pop(L, 1);
break;
Expand All @@ -394,7 +394,7 @@ static char **do_flatten_command(lua_State * L, char **runcmd)
cmdline = malloc(sizeof(char *) * (unsigned) (j + 1));
for (i = 1; i <= (unsigned) j; i++) {
cmdline[i] = NULL;
lua_rawgeti(L, -1, (int) i);
lua_rawgeti(L, 1, (int) i);
if (lua_isnil(L, -1) || (s = lua_tostring(L, -1)) == NULL) {
lua_pop(L, 1);
if (i == 1) {
Expand All @@ -410,7 +410,7 @@ static char **do_flatten_command(lua_State * L, char **runcmd)
}
cmdline[i] = NULL;

lua_rawgeti(L, -1, 0);
lua_rawgeti(L, 1, 0);
if (lua_isnil(L, -1) || (s = lua_tostring(L, -1)) == NULL) {
#ifdef _WIN32
*runcmd = get_command_name(cmdline[0]);
Expand Down Expand Up @@ -546,12 +546,18 @@ static int os_spawn(lua_State * L)
val = lua_tostring(L, -1);
value = xmalloc((unsigned) (strlen(key) + strlen(val) + 2));
sprintf(value, "%s=%s", key, val);
envblock = xreallocarray(envblock, char*, size++ + 1);
envblock = xreallocarray(envblock, char*, size + 1);
envblock[size] = value;
size++;
}
lua_pop(L, 1);
}
envblock[size++] = NULL;
if (envblock) {
envblock[size++] = NULL;
} else {
envblock = xmalloc(sizeof(char *));
envblock[0] = NULL;
}
}
/* If restrictedshell == 0, any command is allowed. */
/* this is a little different from \write18/ os.execute processing
Expand Down
2 changes: 1 addition & 1 deletion texk/web2c/luatexdir/luatex_svnversion.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef luatex_svn_revision_h
#define luatex_svn_revision_h
#define luatex_svn_revision 7664
#define luatex_svn_revision 7665
#endif

0 comments on commit 56bef69

Please sign in to comment.