summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2016-10-05 23:29:07 -0700
committerBenjamin Peterson <benjamin@python.org>2016-10-05 23:29:07 -0700
commitf4009ac6867fd8650336c8b26cc821d62ab6c8b6 (patch)
tree2a2c7a797002b83a17c111762ae0926a076c7c6e /Modules
parent1ed473fc96d1d51979f302d5a14134a5bcd64e05 (diff)
downloadcpython-f4009ac6867fd8650336c8b26cc821d62ab6c8b6.tar.gz
do not leak buffer if mmap is not writable
Diffstat (limited to 'Modules')
-rw-r--r--Modules/mmapmodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 6e2db6134c..e01de441bd 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);