Check for empty string in config_parse_int()

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lars Henriksen 2018-05-28 13:58:40 +02:00 committed by Lukas Fleischer
parent 407d5abd23
commit d5961baa13

View File

@ -151,12 +151,15 @@ static int config_parse_unsigned(unsigned *dest, const char *val)
static int config_parse_int(int *dest, const char *val) static int config_parse_int(int *dest, const char *val)
{ {
if ((*val == '+' || *val == '-' || isdigit(*val)) char *cp = (char *)val;
&& is_all_digit(val + 1))
if (*val == '+' || *val == '-')
cp++;
/* Test for empty string before checking for digits only. */
if (*cp && is_all_digit(cp))
*dest = atoi(val); *dest = atoi(val);
else else
return 0; return 0;
return 1; return 1;
} }