[issue3274] Py_CLEAR(tmp) seg faults
Daniel Stutzbach
report at bugs.python.org
Thu Jul 3 19:54:09 CEST 2008
New submission from Daniel Stutzbach <daniel at stutzbachenterprises.com>:
I'm writing a C extension module and discovered that Py_CLEAR() causes a
crash if the programmer happened to name their variable "tmp". The
Py_CLEAR() macro internally uses the name "tmp" in a new scope, hiding
the callers "tmp", and calling Py_DECREF() on an essentially random bit
of memory.
I suggest changing Py_CLEAR() to use something a little less common than
"tmp". Perhaps "_py_tmp".
For easy reference, here's how Py_CLEAR() is defined now:
#define Py_CLEAR(op) \
do { \
if (op) { \
PyObject *tmp = (PyObject *)(op); \
(op) = NULL; \
Py_DECREF(tmp); \
} \
} while (0)
----------
components: Interpreter Core
messages: 69213
nosy: stutzbach
severity: normal
status: open
title: Py_CLEAR(tmp) seg faults
type: crash
versions: Python 2.5, Python 3.0
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3274>
_______________________________________
More information about the Python-bugs-list
mailing list