Check for empty string in config_parse_int()
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
407d5abd23
commit
d5961baa13
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user