[3.15] gh-151773: Fix NULL dereference in PyContextVar_Set (GH-151836) (#152009)

gh-151773: Fix NULL dereference in `PyContextVar_Set` (GH-151836)
(cherry picked from commit d35b1719a5)

Co-authored-by: dev <b.chouksey27@gmail.com>
This commit is contained in:
Miss Islington (bot) 2026-06-23 16:46:05 +02:00 committed by GitHub
parent 672825e2f3
commit 7b765a47b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View file

@ -362,6 +362,9 @@ PyContextVar_Set(PyObject *ovar, PyObject *val)
Py_XINCREF(old_val);
PyContextToken *tok = token_new(ctx, var, old_val);
Py_XDECREF(old_val);
if (tok == NULL) {
return NULL;
}
if (contextvar_set(var, val)) {
Py_DECREF(tok);