Skip to content

Commit

Permalink
Fixed bug 3338 - console_wmain doesn't null terminate the argv array
Browse files Browse the repository at this point in the history
Simon Hug

The function console_wmain in src/main/windows/SDL_windows_main.c does not null terminate the argument list it is creating. As specified by the C standard, "argv[argc] shall be a null pointer."

The SDLTest framework makes use of that null pointer and some test programs can cause an access violation because it's missing.
  • Loading branch information
slouken committed Oct 1, 2016
1 parent 77305d4 commit 708def8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/windows/SDL_windows_main.c
Expand Up @@ -141,12 +141,13 @@ int
console_wmain(int argc, wchar_t *wargv[], wchar_t *wenvp)
{
int retval = 0;
char **argv = SDL_stack_alloc(char*, argc);
char **argv = SDL_stack_alloc(char*, argc + 1);
int i;

for (i = 0; i < argc; ++i) {
argv[i] = WIN_StringToUTF8(wargv[i]);
}
argv[argc] = NULL;

retval = main_utf8(argc, argv);

Expand Down

0 comments on commit 708def8

Please sign in to comment.