Fixed string quoting on windows in system.exec()

This commit is contained in:
rxi 2020-05-22 08:11:05 +01:00
parent 6b39fb6dfb
commit 35ce3d32a9

View file

@ -335,10 +335,10 @@ static int f_sleep(lua_State *L) {
static int f_exec(lua_State *L) {
size_t len;
const char *cmd = luaL_checklstring(L, 1, &len);
char *buf = malloc(len + 16);
char *buf = malloc(len + 32);
if (!buf) { luaL_error(L, "buffer allocation failed"); }
#if _WIN32
sprintf(buf, "cmd /c %s", cmd);
sprintf(buf, "cmd /c \"%s\"", cmd);
WinExec(buf, SW_HIDE);
#else
sprintf(buf, "%s &", cmd);