diff options
author | Shantanu <12621235+hauntsaninja@users.noreply.github.com> | 2022-11-06 14:05:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-06 14:05:13 (GMT) |
commit | d3b82b4463c4eb51954c0afd98342f0c5e479baa (patch) | |
tree | cc91192e0437782ef3f33d2f89c3002a38354c1b /Modules/_pickle.c | |
parent | 31f2f6568d89564cc1d686cd6b75ba5578aaa748 (diff) | |
download | cpython-d3b82b4463c4eb51954c0afd98342f0c5e479baa.zip cpython-d3b82b4463c4eb51954c0afd98342f0c5e479baa.tar.gz cpython-d3b82b4463c4eb51954c0afd98342f0c5e479baa.tar.bz2 |
gh-83004: Clean up refleak in _pickle initialisation (#98841)
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r-- | Modules/_pickle.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 52704b0..80bb212 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -7986,16 +7986,15 @@ PyInit__pickle(void) if (st->UnpicklingError == NULL) return NULL; - Py_INCREF(st->PickleError); - if (PyModule_AddObject(m, "PickleError", st->PickleError) < 0) + if (PyModule_AddObjectRef(m, "PickleError", st->PickleError) < 0) { return NULL; - Py_INCREF(st->PicklingError); - if (PyModule_AddObject(m, "PicklingError", st->PicklingError) < 0) + } + if (PyModule_AddObjectRef(m, "PicklingError", st->PicklingError) < 0) { return NULL; - Py_INCREF(st->UnpicklingError); - if (PyModule_AddObject(m, "UnpicklingError", st->UnpicklingError) < 0) + } + if (PyModule_AddObjectRef(m, "UnpicklingError", st->UnpicklingError) < 0) { return NULL; - + } if (_Pickle_InitState(st) < 0) return NULL; |