summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-08-22 15:07:02 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2016-08-22 15:07:02 (GMT)
commitc98afb7a26ac611a4544c5b8dd445d8ea05e6360 (patch)
tree0ca23f749d81d88c76524911678bedc4ed9667bf
parentad7b6c3720da0b12296a6fd69d882fc1bc296d99 (diff)
parent4b7b565c581f8f418df6e661ebf7d906794e7142 (diff)
downloadcpython-c98afb7a26ac611a4544c5b8dd445d8ea05e6360.zip
cpython-c98afb7a26ac611a4544c5b8dd445d8ea05e6360.tar.gz
cpython-c98afb7a26ac611a4544c5b8dd445d8ea05e6360.tar.bz2
Issue #27587: Merge from 3.5
-rw-r--r--Misc/NEWS4
-rw-r--r--Python/pystate.c6
2 files changed, 8 insertions, 2 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index cbbb424..c2265d6 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,10 @@ What's New in Python 3.6.0 beta 1
Core and Builtins
-----------------
+- Issue #27587: Fix another issue found by PVS-Studio: Null pointer check
+ after use of 'def' in _PyState_AddModule().
+ Initial patch by Christian Heimes.
+
- Issue #27792: The modulo operation applied to ``bool`` and other
``int`` subclasses now always returns an ``int``. Previously
the return type depended on the input values. Patch by Xiang Zhang.
diff --git a/Python/pystate.c b/Python/pystate.c
index b1aecec..25110b2 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -285,14 +285,16 @@ int
_PyState_AddModule(PyObject* module, struct PyModuleDef* def)
{
PyInterpreterState *state;
+ if (!def) {
+ assert(PyErr_Occurred());
+ return -1;
+ }
if (def->m_slots) {
PyErr_SetString(PyExc_SystemError,
"PyState_AddModule called on module with slots");
return -1;
}
state = GET_INTERP_STATE();
- if (!def)
- return -1;
if (!state->modules_by_index) {
state->modules_by_index = PyList_New(0);
if (!state->modules_by_index)