GH-94736: Fix _multiprocessing.SemLock subclassing (#94738)

* fix allocator and deallocator

* 📜🤖 Added by blurb_it.

* code review

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
This commit is contained in:
Kumar Aditya 2022-07-11 17:42:36 +05:30 committed by GitHub
parent 1fdc35ef51
commit f5b76330cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View file

@ -454,9 +454,7 @@ static PyObject *
newsemlockobject(PyTypeObject *type, SEM_HANDLE handle, int kind, int maxvalue,
char *name)
{
SemLockObject *self;
self = PyObject_New(SemLockObject, type);
SemLockObject *self = (SemLockObject *)type->tp_alloc(type, 0);
if (!self)
return NULL;
self->handle = handle;
@ -573,7 +571,7 @@ semlock_dealloc(SemLockObject* self)
if (self->handle != SEM_FAILED)
SEM_CLOSE(self->handle);
PyMem_Free(self->name);
PyObject_Free(self);
Py_TYPE(self)->tp_free((PyObject*)self);
}
/*[clinic input]