Skip to content

Commit e182e8e

Browse files
committed
Issue #27587: Merge from 3.5
2 parents 06927ab + 64e4613 commit e182e8e

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ What's New in Python 3.6.0 beta 1
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #27587: Fix another issue found by PVS-Studio: Null pointer check
14+
after use of 'def' in _PyState_AddModule().
15+
Initial patch by Christian Heimes.
16+
1317
- Issue #27792: The modulo operation applied to ``bool`` and other
1418
``int`` subclasses now always returns an ``int``. Previously
1519
the return type depended on the input values. Patch by Xiang Zhang.

Python/pystate.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,16 @@ int
285285
_PyState_AddModule(PyObject* module, struct PyModuleDef* def)
286286
{
287287
PyInterpreterState *state;
288+
if (!def) {
289+
assert(PyErr_Occurred());
290+
return -1;
291+
}
288292
if (def->m_slots) {
289293
PyErr_SetString(PyExc_SystemError,
290294
"PyState_AddModule called on module with slots");
291295
return -1;
292296
}
293297
state = GET_INTERP_STATE();
294-
if (!def)
295-
return -1;
296298
if (!state->modules_by_index) {
297299
state->modules_by_index = PyList_New(0);
298300
if (!state->modules_by_index)

0 commit comments

Comments
 (0)