[3.13] gh-126991: Fix reference leak in loading pickle's opcode BUILD (GH-126990) (GH-127018)

If PyObject_SetItem() fails in the `load_build()` function of _pickle.c, no DECREF for the `dict` variable.
(cherry picked from commit 29cbcbd73b)

Co-authored-by: Justin Applegate <70449145+Legoclones@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2024-11-19 19:19:39 +01:00 committed by GitHub
parent 3fae84fe58
commit bb98a0afd8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 0 deletions

View File

@ -6659,6 +6659,7 @@ load_build(PickleState *st, UnpicklerObject *self)
}
if (PyObject_SetItem(dict, d_key, d_value) < 0) {
Py_DECREF(d_key);
Py_DECREF(dict);
goto error;
}
Py_DECREF(d_key);