summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-11-14 00:47:14 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-11-14 00:47:14 (GMT)
commit6a3db25c70965790893e51febe139215b22b40c5 (patch)
tree7748484fc18524e06a30c2de4bf0755254e64c40 /Objects
parent507eabdf11d34cd95cbe44ba876af0a414d7f597 (diff)
downloadcpython-6a3db25c70965790893e51febe139215b22b40c5.zip
cpython-6a3db25c70965790893e51febe139215b22b40c5.tar.gz
cpython-6a3db25c70965790893e51febe139215b22b40c5.tar.bz2
Issue #17828: _PyObject_GetDictPtr() may return NULL instead of a PyObject**
CID 1128792: Dereference null return value (NULL_RETURNS)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/exceptions.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 2f0d5b6..94f581b 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -2626,7 +2626,7 @@ _PyErr_TrySetFromCause(const char *format, ...)
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 @@ _PyErr_TrySetFromCause(const char *format, ...)
}
/* 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