Skip to content
Closed
Prev Previous commit
Clean up refleaks in _bz2 initialization.
  • Loading branch information
brandtbucher committed Jan 28, 2020
commit 95f9800880007ff0fbd5b52834c6b6a9c678a42f
15 changes: 12 additions & 3 deletions Modules/_bz2module.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,11 +755,20 @@ PyInit__bz2(void)
return NULL;

Py_INCREF(&BZ2Compressor_Type);
PyModule_AddObject(m, "BZ2Compressor", (PyObject *)&BZ2Compressor_Type);
if (_PyModule_StealObject(m, "BZ2Compressor",
(PyObject *)&BZ2Compressor_Type) < 0) {
goto fail;
}

Py_INCREF(&BZ2Decompressor_Type);
PyModule_AddObject(m, "BZ2Decompressor",
(PyObject *)&BZ2Decompressor_Type);
if (_PyModule_StealObject(m, "BZ2Decompressor",
(PyObject *)&BZ2Decompressor_Type) < 0) {
goto fail;
}

return m;

fail:
Py_DECREF(m);
return NULL;
}