From c03979d004792acaed242f9f7c7496fc5e92936e Mon Sep 17 00:00:00 2001 From: Andrewerr Date: Sun, 31 Dec 2017 15:43:35 +0300 Subject: [PATCH] Fixed issue #5 --- util.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/util.c b/util.c index 3217639..45e9002 100644 --- a/util.c +++ b/util.c @@ -7,6 +7,7 @@ // #include "util.h" +#include "message.h" #include int randport() { @@ -38,8 +39,10 @@ const char* getarg(const char arg[2], const char* argv[], int argc) #endif if (!strcmp(arg, argv[i])) { - if (i < argc) { + if (i < argc-1) { return argv[i + 1]; + }else{ + die("Argument required for key:%s",arg); } } } @@ -54,8 +57,10 @@ const char* getlarg(const char* arg, const char* argv[], int argc) #endif if (!strcmp(arg, argv[i])) { - if (i < argc) { + if (i < argc-1) { return argv[i + 1]; + }else{ + die("Argument required for key:%s",arg); } } }