summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-04-03 21:11:18 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2011-04-03 21:31:32 +0200
commit1473145d10a0ba529526897c08eab2fb176dac01 (patch)
tree75ae749e4b1f835114a48d38876450f0563859e7
parent6ff95238766656c5ea9d5c65c35d3aef93499f60 (diff)
downloadcalcurse-1473145d10a0ba529526897c08eab2fb176dac01.tar.gz
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>
-rw-r--r--src/utils.c8
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: