bpo-32710: Fix leak in Overlapped_WSASend() (GH-11469)

Fix a memory leak in asyncio in the ProactorEventLoop when ReadFile()
or WSASend() overlapped operation fail immediately: release the
internal buffer.
(cherry picked from commit a234e14839)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
This commit is contained in:
Miss Islington (bot) 2019-01-08 05:40:50 -08:00 committed by GitHub
parent 69f64b67e4
commit 88ad48bc98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -0,0 +1,3 @@
Fix a memory leak in asyncio in the ProactorEventLoop when ``ReadFile()`` or
``WSASend()`` overlapped operation fail immediately: release the internal
buffer.

View File

@ -723,6 +723,7 @@ do_ReadFile(OverlappedObject *self, HANDLE handle,
case ERROR_IO_PENDING:
Py_RETURN_NONE;
default:
PyBuffer_Release(&self->user_buffer);
self->type = TYPE_NOT_STARTED;
return SetFromWindowsErr(err);
}
@ -1011,6 +1012,7 @@ Overlapped_WSASend(OverlappedObject *self, PyObject *args)
case ERROR_IO_PENDING:
Py_RETURN_NONE;
default:
PyBuffer_Release(&self->user_buffer);
self->type = TYPE_NOT_STARTED;
return SetFromWindowsErr(err);
}