[Python-checkins] r80739 - python/trunk/Modules/datetimemodule.c

brett.cannon python-checkins at python.org
Tue May 4 02:36:00 CEST 2010


Author: brett.cannon
Date: Tue May  4 02:36:00 2010
New Revision: 80739

Log:
Prevent a possible NULL de-reference and an unneeded variable assignment.

Found using Clang's static analyzer.


Modified:
   python/trunk/Modules/datetimemodule.c

Modified: python/trunk/Modules/datetimemodule.c
==============================================================================
--- python/trunk/Modules/datetimemodule.c	(original)
+++ python/trunk/Modules/datetimemodule.c	Tue May  4 02:36:00 2010
@@ -1520,7 +1520,7 @@
 		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 @@
 			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;


More information about the Python-checkins mailing list