gh-134885: zstd: Use Py_XSETREF (GH-134886)

This commit is contained in:
Jelle Zijlstra 2025-05-30 02:30:05 -07:00 committed by GitHub
parent b367e27af9
commit 45c6c48afc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 7 deletions

View file

@ -0,0 +1,2 @@
Fix possible crash in the :mod:`compression.zstd` module related to setting
parameter types. Patch by Jelle Zijlstra.

View file

@ -514,13 +514,10 @@ _zstd_set_parameter_types_impl(PyObject *module, PyObject *c_parameter_type,
return NULL;
}
Py_XDECREF(mod_state->CParameter_type);
Py_INCREF(c_parameter_type);
mod_state->CParameter_type = (PyTypeObject*)c_parameter_type;
Py_XDECREF(mod_state->DParameter_type);
Py_INCREF(d_parameter_type);
mod_state->DParameter_type = (PyTypeObject*)d_parameter_type;
Py_XSETREF(
mod_state->CParameter_type, (PyTypeObject*)Py_NewRef(c_parameter_type));
Py_XSETREF(
mod_state->DParameter_type, (PyTypeObject*)Py_NewRef(d_parameter_type));
Py_RETURN_NONE;
}