Skip to content

Commit

Permalink
add checks before accessing argv[0]
Browse files Browse the repository at this point in the history
This makes comcom64 compatible with silly -l loader that doesn't
support args.

See dosemu2/dosemu2#2398
  • Loading branch information
stsp committed Mar 2, 2025
1 parent f541cef commit 37f4a7d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -4644,7 +4644,7 @@ void do_int0(void)
int main(int argc, const char *argv[], const char *envp[])
{
int a;
char *cmd_path, *v;
char *v;
int disable_autoexec = 0;
int inited = 0;
// initialize the cmd data ...
Expand Down Expand Up @@ -4672,12 +4672,14 @@ int main(int argc, const char *argv[], const char *envp[])

// init bat file stack
reset_batfile_call_stack();

cmd_path = strdup(argv[0]);
strupr(cmd_path);
conv_unix_path_to_ms_dos(cmd_path);
setenv("COMSPEC", cmd_path, 1);
free(cmd_path);
if (argc > 0 && !getenv("COMSPEC"))
{
char *cmd_path = strdup(argv[0]);
strupr(cmd_path);
conv_unix_path_to_ms_dos(cmd_path);
setenv("COMSPEC", cmd_path, 1);
free(cmd_path);
}
setenv("COMCOM_VER", version, 1);
setenv("ERRORLEVEL", "0", 1);
setenv("TERM", "djgpp", 0);
Expand Down

0 comments on commit 37f4a7d

Please sign in to comment.