summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-08-12 02:06:34 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-08-12 02:06:34 (GMT)
commit6b4953fd3d3d1df06f692af67f593d3d0a7aef26 (patch)
tree6b659e9036a0e6961855205920251a5b0bd6d647
parentb45f351832b00c80bf9881e92b12c330324e3116 (diff)
downloadcpython-6b4953fd3d3d1df06f692af67f593d3d0a7aef26.zip
cpython-6b4953fd3d3d1df06f692af67f593d3d0a7aef26.tar.gz
cpython-6b4953fd3d3d1df06f692af67f593d3d0a7aef26.tar.bz2
Check returned pointer is valid.
Klocwork #233
-rwxr-xr-xLib/test/regrtest.py7
-rw-r--r--Modules/_ctypes/cfield.c6
-rw-r--r--Objects/funcobject.c5
-rw-r--r--Python/ceval.c9
-rw-r--r--Python/pythonrun.c3
5 files changed, 28 insertions, 2 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 4553838..8c416f1 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -123,6 +123,7 @@ option '-uall,-bsddb'.
import os
import sys
+import signal
import getopt
import random
import warnings
@@ -289,6 +290,12 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
if single and fromfile:
usage(2, "-s and -f don't go together!")
+ def handle_signal(*args):
+ raise RuntimeError('signal received %s' % args)
+
+ # Provide a traceback if we are terminated.
+ signal.signal(signal.SIGTERM, handle_signal)
+
good = []
bad = []
skipped = []
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index 3595b05..62a5fe6 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -105,6 +105,12 @@ CField_FromDesc(PyObject *desc, int index,
StgDictObject *idict;
if (adict && adict->proto) {
idict = PyType_stgdict(adict->proto);
+ if (!idict) {
+ PyErr_SetString(PyExc_TypeError,
+ "has no _stginfo_");
+ Py_DECREF(self);
+ return NULL;
+ }
if (idict->getfunc == getentry("c")->getfunc) {
struct fielddesc *fd = getentry("s");
getfunc = fd->getfunc;
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 1ba74c5..b972e08 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -486,9 +486,10 @@ function_call(PyObject *func, PyObject *arg, PyObject *kw)
Py_ssize_t nk, nd;
argdefs = PyFunction_GET_DEFAULTS(func);
+ /* XXX(nnorwitz): don't we know argdefs is either NULL or a tuple? */
if (argdefs != NULL && PyTuple_Check(argdefs)) {
d = &PyTuple_GET_ITEM((PyTupleObject *)argdefs, 0);
- nd = PyTuple_Size(argdefs);
+ nd = PyTuple_GET_SIZE(argdefs);
}
else {
d = NULL;
@@ -517,7 +518,7 @@ function_call(PyObject *func, PyObject *arg, PyObject *kw)
result = PyEval_EvalCodeEx(
(PyCodeObject *)PyFunction_GET_CODE(func),
PyFunction_GET_GLOBALS(func), (PyObject *)NULL,
- &PyTuple_GET_ITEM(arg, 0), PyTuple_Size(arg),
+ &PyTuple_GET_ITEM(arg, 0), PyTuple_GET_SIZE(arg),
k, nk, d, nd,
PyFunction_GET_CLOSURE(func));
diff --git a/Python/ceval.c b/Python/ceval.c
index a0e8b30..6d2b17f 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -230,6 +230,15 @@ PyEval_InitThreads(void)
}
void
+_PyEval_FiniThreads(void)
+{
+ if (interpreter_lock)
+ PyThread_free_lock(interpreter_lock);
+ interpreter_lock = 0;
+ main_thread = 0;
+}
+
+void
PyEval_AcquireLock(void)
{
PyThread_acquire_lock(interpreter_lock, 1);
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 88fd67c..80f6232 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -60,6 +60,7 @@ static void call_sys_exitfunc(void);
static void call_ll_exitfuncs(void);
extern void _PyUnicode_Init(void);
extern void _PyUnicode_Fini(void);
+extern void _PyEval_FiniThreads(void);
#ifdef WITH_THREAD
extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *);
@@ -461,6 +462,8 @@ Py_Finalize(void)
_PyUnicode_Fini();
#endif
+ _PyEval_FiniThreads();
+
/* XXX Still allocated:
- various static ad-hoc pointers to interned strings
- int and float free list blocks