Skip to content

Commit

Permalink
Fixed issue in ls_proc_start_shell
Browse files Browse the repository at this point in the history
  • Loading branch information
evrhel committed May 18, 2024
1 parent 0917dbc commit 23707ad
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/ls_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,9 @@ ls_handle ls_proc_start_shell(const char *path, const char *argv[], const struct
#if LS_WINDOWS
char cmd[MAX_PATH];
size_t len;
size_t argv_len;
const char **new_argv;
size_t i;
const char *new_argv[3];
ls_handle ph;
LPWSTR lpCmd;

if (!path)
{
Expand All @@ -312,19 +311,25 @@ ls_handle ls_proc_start_shell(const char *path, const char *argv[], const struct
return NULL;
}

argv_len = argv ? salen(argv) : 0;
new_argv = ls_malloc((argv_len + 2) * sizeof(char *));
if (!new_argv)
lpCmd = ls_build_command_line(path, argv);
if (!lpCmd)
return NULL;

new_argv[0] = "/C";
for (i = 0; i < argv_len; i++)
new_argv[i + 1] = argv[i];
new_argv[argv_len + 1] = NULL;

new_argv[1] = ls_wchar_to_utf8(lpCmd);
if (!new_argv[1])
{
ls_free(lpCmd);
return NULL;
}

new_argv[2] = NULL;

ph = ls_proc_start(cmd, new_argv, info);

ls_free(new_argv);
ls_free(new_argv[1]);
ls_free(lpCmd);

return ph;
#else
Expand Down

0 comments on commit 23707ad

Please sign in to comment.