From c083462a6327a8dd5fab346839bc8c394e8a92d7 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 19 May 2024 05:23:47 +0400 Subject: [PATCH] Actually, argv[i] cannot has a length of 0, so let's compare here against 1, meaning there was just a '-' was passed. --- kwh-cost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kwh-cost.c b/kwh-cost.c index e7aa237..8c4d79d 100644 --- a/kwh-cost.c +++ b/kwh-cost.c @@ -40,7 +40,7 @@ int parse_arguments(const int argc, const char *const *const argv, for (int i = 1, pos = 0; i < argc; ++i) if (argv[i][0] == '-') { size_t l = strlen(argv[i]); - if (l < 2) + if (l == 1) return 99; if (argv[i][1] == 'h' || (argv[i][1] == '-' && l > 2 && argv[i][2] == 'h')) return 1;