[Python-checkins] cpython: Issue #17828: _PyObject_GetDictPtr() may return NULL instead of a PyObject**
christian.heimes
python-checkins at python.org
Thu Nov 14 01:48:42 CET 2013
http://hg.python.org/cpython/rev/26121ae22016
changeset: 87093:26121ae22016
parent: 87089:99ba1772c469
user: Christian Heimes <christian at cheimes.de>
date: Thu Nov 14 01:47:14 2013 +0100
summary:
Issue #17828: _PyObject_GetDictPtr() may return NULL instead of a PyObject**
CID 1128792: Dereference null return value (NULL_RETURNS)
files:
Objects/exceptions.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -2626,7 +2626,7 @@
PyObject* msg_prefix;
PyObject *exc, *val, *tb;
PyTypeObject *caught_type;
- PyObject *instance_dict;
+ PyObject **dictptr;
PyObject *instance_args;
Py_ssize_t num_args;
PyObject *new_exc, *new_val, *new_tb;
@@ -2664,8 +2664,10 @@
}
/* Ensure the instance dict is also empty */
- instance_dict = *_PyObject_GetDictPtr(val);
- if (instance_dict != NULL && PyObject_Length(instance_dict) > 0) {
+ dictptr = _PyObject_GetDictPtr(val);
+ if ((dictptr != NULL) && (*dictptr != NULL) &&
+ (PyObject_Length(*dictptr) > 0)
+ ) {
/* While we could potentially copy a non-empty instance dictionary
* to the replacement exception, for now we take the more
* conservative path of leaving exceptions with attributes set
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list