diff options
author | Lars Henriksen <LarsHenriksen@get2net.dk> | 2018-05-28 13:58:40 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2018-05-28 17:31:06 +0200 |
commit | d5961baa13127cc4b02a5e88bb11dc7c8e47d3a8 (patch) | |
tree | db663fc94e61168b3dad646be26d4a1bc1aa4b11 /src | |
parent | 407d5abd231eeedb9bfdc5e81b9ef7030bb05325 (diff) | |
download | calcurse-d5961baa13127cc4b02a5e88bb11dc7c8e47d3a8.tar.gz calcurse-d5961baa13127cc4b02a5e88bb11dc7c8e47d3a8.zip |
Check for empty string in config_parse_int()
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/config.c | 9 |
1 files changed, 6 insertions, 3 deletions
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; } |