From 1c587be39b39033329510ec74631709fa4213864 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Thu, 27 Jan 2022 00:21:28 +0100 Subject: [PATCH] Gracefully handle an *empty* argument array (argc < 1), which apparently is possible on Linux and maybe others. --- frontend/src/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/src/main.c b/frontend/src/main.c index cea5e71..a781d9f 100644 --- a/frontend/src/main.c +++ b/frontend/src/main.c @@ -158,6 +158,12 @@ int MAIN(const int argc, CHR *const argv[]) /* Parse arguments */ /* ----------------------------------------------------- */ + if (argc < 1) + { + FPUTS(T("Error: Argument array is empty. The program was called incorrectly!\n\n"), stderr); + goto clean_up; + } + if (argc < 2) { FPRINTF(stderr, T("Error: Nothing to do. Please type '%") T(PRISTR) T(" --help' for details!\n\n"), get_file_name(argv[0U]));