summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2010-05-04 00:36:00 (GMT)
committerBrett Cannon <bcannon@gmail.com>2010-05-04 00:36:00 (GMT)
commit87ab6ad4d6b8f5cfc1e0d56ea9520e99a99a8883 (patch)
treed4368d6647809afbafc8228f76769762c3455df3
parente894e93f4c5be0ab3a7c7cc59830723610599ad6 (diff)
downloadcpython-87ab6ad4d6b8f5cfc1e0d56ea9520e99a99a8883.zip
cpython-87ab6ad4d6b8f5cfc1e0d56ea9520e99a99a8883.tar.gz
cpython-87ab6ad4d6b8f5cfc1e0d56ea9520e99a99a8883.tar.bz2
Prevent a possible NULL de-reference and an unneeded variable assignment.
Found using Clang's static analyzer.
-rw-r--r--Modules/datetimemodule.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c
index 402dae9..fa7ef0b 100644
--- a/Modules/datetimemodule.c
+++ b/Modules/datetimemodule.c
@@ -1520,7 +1520,7 @@ delta_to_microseconds(PyDateTime_Delta *self)
goto Done;
Py_DECREF(x1);
Py_DECREF(x2);
- x1 = x2 = NULL;
+ x2 = NULL;
/* x3 has days+seconds in seconds */
x1 = PyNumber_Multiply(x3, us_per_second); /* us */
@@ -3952,7 +3952,7 @@ datetime_strptime(PyObject *cls, PyObject *args)
else
good_timetuple = 0;
/* follow that up with a little dose of microseconds */
- if (PyInt_Check(frac))
+ if (good_timetuple && PyInt_Check(frac))
ia[6] = PyInt_AsLong(frac);
else
good_timetuple = 0;