From d5961baa13127cc4b02a5e88bb11dc7c8e47d3a8 Mon Sep 17 00:00:00 2001
From: Lars Henriksen <LarsHenriksen@get2net.dk>
Date: Mon, 28 May 2018 13:58:40 +0200
Subject: Check for empty string in config_parse_int()

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
---
 src/config.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

(limited to 'src')

diff --git a/src/config.c b/src/config.c
index 8dbfa31..ff66fce 100644
--- a/src/config.c
+++ b/src/config.c
@@ -151,12 +151,15 @@ static int config_parse_unsigned(unsigned *dest, const char *val)
 
 static int config_parse_int(int *dest, const char *val)
 {
-	if ((*val == '+' || *val == '-' || isdigit(*val))
-	    && is_all_digit(val + 1))
+	char *cp = (char *)val;
+
+	if (*val == '+' || *val == '-')
+		cp++;
+	/* Test for empty string before checking for digits only. */
+	if (*cp && is_all_digit(cp))
 		*dest = atoi(val);
 	else
 		return 0;
-
 	return 1;
 }
 
-- 
cgit v1.2.3-70-g09d2