diff options
author | Luigi Scarso <luigi.scarso@gmail.com> | 2025-02-11 08:28:38 +0000 |
---|---|---|
committer | Luigi Scarso <luigi.scarso@gmail.com> | 2025-02-11 08:28:38 +0000 |
commit | 8aa1145b2976ba28e90a07283316ce63b470293c (patch) | |
tree | bc610e4c4d53db3ad6e31f2866bcffaa6a392a08 /Build/source | |
parent | cf9bc2d58e6d3e9f57fa6c83f678efb590e4b1f3 (diff) |
LuaTeX: Fix bugs in "os.spawn" second argument (thanks to tex@maxchernoff.ca)
git-svn-id: svn://tug.org/texlive/trunk@73874 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/lua/loslibext.c | 16 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/luatex_svnversion.h | 2 |
2 files changed, 12 insertions, 6 deletions
diff --git a/Build/source/texk/web2c/luatexdir/lua/loslibext.c b/Build/source/texk/web2c/luatexdir/lua/loslibext.c index e184a4624a6..b013c42a637 100644 --- a/Build/source/texk/web2c/luatexdir/lua/loslibext.c +++ b/Build/source/texk/web2c/luatexdir/lua/loslibext.c @@ -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; @@ -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) { @@ -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]); @@ -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 diff --git a/Build/source/texk/web2c/luatexdir/luatex_svnversion.h b/Build/source/texk/web2c/luatexdir/luatex_svnversion.h index aad2746ab8a..9132d0eccda 100644 --- a/Build/source/texk/web2c/luatexdir/luatex_svnversion.h +++ b/Build/source/texk/web2c/luatexdir/luatex_svnversion.h @@ -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 |