mirror of
https://github.com/python/cpython.git
synced 2025-12-04 16:43:27 +00:00
Issue #17828: _PyObject_GetDictPtr() may return NULL instead of a PyObject**
CID 1128792: Dereference null return value (NULL_RETURNS)
This commit is contained in:
parent
507eabdf11
commit
6a3db25c70
1 changed files with 5 additions and 3 deletions
|
|
@ -2626,7 +2626,7 @@ _PyErr_TrySetFromCause(const char *format, ...)
|
||||||
PyObject* msg_prefix;
|
PyObject* msg_prefix;
|
||||||
PyObject *exc, *val, *tb;
|
PyObject *exc, *val, *tb;
|
||||||
PyTypeObject *caught_type;
|
PyTypeObject *caught_type;
|
||||||
PyObject *instance_dict;
|
PyObject **dictptr;
|
||||||
PyObject *instance_args;
|
PyObject *instance_args;
|
||||||
Py_ssize_t num_args;
|
Py_ssize_t num_args;
|
||||||
PyObject *new_exc, *new_val, *new_tb;
|
PyObject *new_exc, *new_val, *new_tb;
|
||||||
|
|
@ -2664,8 +2664,10 @@ _PyErr_TrySetFromCause(const char *format, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ensure the instance dict is also empty */
|
/* Ensure the instance dict is also empty */
|
||||||
instance_dict = *_PyObject_GetDictPtr(val);
|
dictptr = _PyObject_GetDictPtr(val);
|
||||||
if (instance_dict != NULL && PyObject_Length(instance_dict) > 0) {
|
if ((dictptr != NULL) && (*dictptr != NULL) &&
|
||||||
|
(PyObject_Length(*dictptr) > 0)
|
||||||
|
) {
|
||||||
/* While we could potentially copy a non-empty instance dictionary
|
/* While we could potentially copy a non-empty instance dictionary
|
||||||
* to the replacement exception, for now we take the more
|
* to the replacement exception, for now we take the more
|
||||||
* conservative path of leaving exceptions with attributes set
|
* conservative path of leaving exceptions with attributes set
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue