From 708def87f318398c9b3c473148c23665eaaf71ea Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 1 Oct 2016 11:48:15 -0700 Subject: [PATCH] Fixed bug 3338 - console_wmain doesn't null terminate the argv array 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. --- src/main/windows/SDL_windows_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/windows/SDL_windows_main.c b/src/main/windows/SDL_windows_main.c index e6378081f..67ef98e6c 100644 --- a/src/main/windows/SDL_windows_main.c +++ b/src/main/windows/SDL_windows_main.c @@ -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);