mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-23 00:36:42 -10:00
getopt_long() scanned for the next option with `for (; argv[idx]; )`, and took an option's argument from argv[1] unchecked: it relied on the NULL a real main() places after the last argument. An argv a caller builds itself may not have one - the threaded-video harness's did not - and then the scan reads whatever the stack held, which under gdb on the Windows runner was not a NULL: a segfault in __getopt_long_retro() from retroarch_main_init(), before the first lane. The scan and the argument reads are now bounded by argc, so the parser never looks past what it was given; the harness also terminates its argv, as a main()'s is.