[issue26868] Incorrect check for return value of PyModule_AddObject in _csv.c
Berker Peksag
report at bugs.python.org
Wed Apr 27 01:36:44 EDT 2016
New submission from Berker Peksag:
This is probably harmless, but Modules/_csv.c has the following code:
Py_INCREF(&Dialect_Type);
if (PyModule_AddObject(module, "Dialect", (PyObject *)&Dialect_Type))
return NULL;
However, PyModule_AddObject returns only -1 and 0. It also doesn't decref Dialect_Type if it returns -1 so I guess more correct code should be:
Py_INCREF(&Dialect_Type);
if (PyModule_AddObject(module, "Dialect", (PyObject *)&Dialect_Type) == -1) {
Py_DECREF(&Dialect_Type);
return NULL;
}
The same pattern can be found in a few more modules.
----------
components: Extension Modules
files: csv.diff
keywords: patch
messages: 264350
nosy: berker.peksag
priority: low
severity: normal
stage: patch review
status: open
title: Incorrect check for return value of PyModule_AddObject in _csv.c
type: behavior
versions: Python 3.5, Python 3.6
Added file: http://bugs.python.org/file42623/csv.diff
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26868>
_______________________________________
More information about the Python-bugs-list
mailing list