From 738d17ff3bae8be1b042f9613456771b37f3ac23 Mon Sep 17 00:00:00 2001 From: Ash Date: Sat, 19 Aug 2017 17:16:50 +1000 Subject: [PATCH] Fix null deref where argc = 0 I noticed this on the Wii U emulator Decaf - it sets argc to 0 and, annoyingly, sets up argv so that argv[0] is a bad read. Gah. --- libretro-common/compat/compat_getopt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/compat/compat_getopt.c b/libretro-common/compat/compat_getopt.c index c32c85865b..95d1bce523 100644 --- a/libretro-common/compat/compat_getopt.c +++ b/libretro-common/compat/compat_getopt.c @@ -184,7 +184,7 @@ int getopt_long(int argc, char *argv[], if (optind == 0) optind = 1; - if (argc == 1) + if (argc < 2) return -1; short_index = find_short_index(&argv[optind]);