diff --git a/src/os/os2/os2.cpp b/src/os/os2/os2.cpp index eb3671029d..386cc4dbb7 100644 --- a/src/os/os2/os2.cpp +++ b/src/os/os2/os2.cpp @@ -174,6 +174,9 @@ int CDECL main(int argc, char *argv[]) { SetRandomSeed(time(NULL)); + /* Make sure our arguments contain only valid UTF-8 characters. */ + for (int i = 0; i < argc; i++) ValidateString(argv[i]); + return openttd_main(argc, argv); } diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp index 59d40cc89f..24dedb2ee1 100644 --- a/src/os/unix/unix.cpp +++ b/src/os/unix/unix.cpp @@ -259,7 +259,8 @@ void cocoaReleaseAutoreleasePool(); int CDECL main(int argc, char *argv[]) { - int ret; + /* Make sure our arguments contain only valid UTF-8 characters. */ + for (int i = 0; i < argc; i++) ValidateString(argv[i]); #ifdef WITH_COCOA cocoaSetupAutoreleasePool(); @@ -275,7 +276,7 @@ int CDECL main(int argc, char *argv[]) signal(SIGPIPE, SIG_IGN); - ret = openttd_main(argc, argv); + int ret = openttd_main(argc, argv); #ifdef WITH_COCOA cocoaReleaseAutoreleasePool(); diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index 3d5f0ebde5..f69f01f6cb 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -453,6 +453,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi argc = ParseCommandLine(cmdline, argv, lengthof(argv)); + /* Make sure our arguments contain only valid UTF-8 characters. */ + for (int i = 0; i < argc; i++) ValidateString(argv[i]); + openttd_main(argc, argv); free(cmdline); return 0;