From 3776836f675f3d52b21713a45460f09a03af15df Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Wed, 5 Oct 2016 23:29:07 -0700 Subject: do not leak buffer if mmap is not writable --- Modules/mmapmodule.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 6e2db61..e01de44 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -383,8 +383,10 @@ mmap_write_method(mmap_object *self, if (!PyArg_ParseTuple(args, "y*:write", &data)) return(NULL); - if (!is_writable(self)) + if (!is_writable(self)) { + PyBuffer_Release(&data); return NULL; + } if (self->pos > self->size || self->size - self->pos < data.len) { PyBuffer_Release(&data); -- cgit v0.12