[Python-checkins] r42882 - in python/branches/release24-maint: Lib/test/test_hotshot.py Modules/_hotshot.c Modules/_sre.c Modules/audioop.c Modules/regexmodule.c
thomas.wouters
python-checkins at python.org
Tue Mar 7 13:08:43 CET 2006
Author: thomas.wouters
Date: Tue Mar 7 13:08:42 2006
New Revision: 42882
Modified:
python/branches/release24-maint/Lib/test/test_hotshot.py
python/branches/release24-maint/Modules/_hotshot.c
python/branches/release24-maint/Modules/_sre.c
python/branches/release24-maint/Modules/audioop.c
python/branches/release24-maint/Modules/regexmodule.c
Log:
Backport trunk's r42878 (neal.norwitz):
Thanks to Coverity, these were all reported by their Prevent tool.
and r42881 (thomas.wouters):
Don't DECREF a borrowed reference.
Modified: python/branches/release24-maint/Lib/test/test_hotshot.py
==============================================================================
--- python/branches/release24-maint/Lib/test/test_hotshot.py (original)
+++ python/branches/release24-maint/Lib/test/test_hotshot.py Tue Mar 7 13:08:42 2006
@@ -107,6 +107,19 @@
profiler.close()
os.unlink(self.logfn)
+ def test_bad_sys_path(self):
+ import sys
+ orig_path = sys.path
+ coverage = hotshot._hotshot.coverage
+ try:
+ # verify we require a list for sys.path
+ sys.path = 'abc'
+ self.assertRaises(RuntimeError, coverage, test_support.TESTFN)
+ # verify sys.path exists
+ del sys.path
+ self.assertRaises(RuntimeError, coverage, test_support.TESTFN)
+ finally:
+ sys.path = orig_path
def test_main():
test_support.run_unittest(HotShotTestCase)
Modified: python/branches/release24-maint/Modules/_hotshot.c
==============================================================================
--- python/branches/release24-maint/Modules/_hotshot.c (original)
+++ python/branches/release24-maint/Modules/_hotshot.c Tue Mar 7 13:08:42 2006
@@ -473,6 +473,8 @@
}
else if (!err) {
result = PyTuple_New(4);
+ if (result == NULL)
+ return NULL;
PyTuple_SET_ITEM(result, 0, PyInt_FromLong(what));
PyTuple_SET_ITEM(result, 2, PyInt_FromLong(fileno));
if (s1 == NULL)
@@ -1486,6 +1488,10 @@
getcwd(cwdbuffer, sizeof cwdbuffer));
temp = PySys_GetObject("path");
+ if (temp == NULL || !PyList_Check(temp)) {
+ PyErr_SetString(PyExc_RuntimeError, "sys.path must be a list");
+ return -1;
+ }
len = PyList_GET_SIZE(temp);
for (i = 0; i < len; ++i) {
PyObject *item = PyList_GET_ITEM(temp, i);
Modified: python/branches/release24-maint/Modules/_sre.c
==============================================================================
--- python/branches/release24-maint/Modules/_sre.c (original)
+++ python/branches/release24-maint/Modules/_sre.c Tue Mar 7 13:08:42 2006
@@ -2980,7 +2980,7 @@
return result;
failed:
- Py_DECREF(keys);
+ Py_XDECREF(keys);
Py_DECREF(result);
return NULL;
}
Modified: python/branches/release24-maint/Modules/audioop.c
==============================================================================
--- python/branches/release24-maint/Modules/audioop.c (original)
+++ python/branches/release24-maint/Modules/audioop.c Tue Mar 7 13:08:42 2006
@@ -1013,6 +1013,8 @@
while (d < 0) {
if (len == 0) {
samps = PyTuple_New(nchannels);
+ if (samps == NULL)
+ goto exit;
for (chan = 0; chan < nchannels; chan++)
PyTuple_SetItem(samps, chan,
Py_BuildValue("(ii)",
Modified: python/branches/release24-maint/Modules/regexmodule.c
==============================================================================
--- python/branches/release24-maint/Modules/regexmodule.c (original)
+++ python/branches/release24-maint/Modules/regexmodule.c Tue Mar 7 13:08:42 2006
@@ -535,8 +535,7 @@
gdict = PyDict_New();
if (gdict == NULL || (npattern = symcomp(pattern, gdict)) == NULL) {
- Py_DECREF(gdict);
- Py_DECREF(pattern);
+ Py_XDECREF(gdict);
return NULL;
}
retval = newregexobject(npattern, tran, pattern, gdict);
More information about the Python-checkins
mailing list