]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_operate: check argc before accessing argv[1]
authorDaniel Stenberg <daniel@haxx.se>
Fri, 26 Feb 2021 14:00:51 +0000 (15:00 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 26 Feb 2021 23:25:47 +0000 (00:25 +0100)
Follow-up to 09363500b
Reported-by: Emil Engler
Reviewed-by: Daniel Gustafsson
Closes #6668

src/tool_operate.c

index e2b287269a6ae5e2136072dee58da8564dd67927..f36f3ce530e32f5f3f2918227af86682495afaf7 100644 (file)
@@ -2574,7 +2574,7 @@ static CURLcode run_all_transfers(struct GlobalConfig *global,
 CURLcode operate(struct GlobalConfig *global, int argc, argv_item_t argv[])
 {
   CURLcode result = CURLE_OK;
-  char *first_arg = curlx_convert_tchar_to_UTF8(argv[1]);
+  char *first_arg = argc > 1 ? curlx_convert_tchar_to_UTF8(argv[1]) : NULL;
 
   /* Setup proper locale from environment */
 #ifdef HAVE_SETLOCALE