]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Prevent a possible NULL de-reference and an unneeded variable assignment.
authorBrett Cannon <bcannon@gmail.com>
Tue, 4 May 2010 00:36:00 +0000 (00:36 +0000)
committerBrett Cannon <bcannon@gmail.com>
Tue, 4 May 2010 00:36:00 +0000 (00:36 +0000)
Found using Clang's static analyzer.

Modules/datetimemodule.c

index 402dae9cd95d5404a66be61c8b9685e9ac687281..fa7ef0b71b32a40c91c9e1c42d9a2f85e7ecfea1 100644 (file)
@@ -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;