diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2011-04-03 21:11:18 +0200 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2011-04-03 21:31:32 +0200 |
commit | 1473145d10a0ba529526897c08eab2fb176dac01 (patch) | |
tree | 75ae749e4b1f835114a48d38876450f0563859e7 /src | |
parent | 6ff95238766656c5ea9d5c65c35d3aef93499f60 (diff) | |
download | calcurse-1473145d10a0ba529526897c08eab2fb176dac01.zip |
Avoid assignment of undefined value in parse_date().
Spotted by clang-analyzer ("Assigned value is garbage or undefined").
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/utils.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/utils.c b/src/utils.c index 6fc784c..8e4a447 100644 --- a/src/utils.c +++ b/src/utils.c @@ -824,8 +824,8 @@ parse_date (char *date_string, enum datefmt datefmt, int *year, int *month, switch (datefmt) { case DATEFMT_MMDDYYYY: - m = in[n > 0 ? 0 : 1]; - d = in[n > 0 ? 1 : 0]; + m = (n >= 1) ? in[0] : 0; + d = (n >= 1) ? in[1] : in[0]; y = in[2]; break; case DATEFMT_DDMMYYYY: @@ -835,8 +835,8 @@ parse_date (char *date_string, enum datefmt datefmt, int *year, int *month, break; case DATEFMT_YYYYMMDD: case DATEFMT_ISO: - y = in[0]; - m = in[n - 1]; + y = (n >= 2) ? in[n - 2] : 0; + m = (n >= 1) ? in[n - 1] : 0; d = in[n]; break; default: |