diff options
author | Benjamin Peterson <benjamin@python.org> | 2016-10-05 23:29:07 -0700 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2016-10-05 23:29:07 -0700 |
commit | f4009ac6867fd8650336c8b26cc821d62ab6c8b6 (patch) | |
tree | 2a2c7a797002b83a17c111762ae0926a076c7c6e /Modules | |
parent | 1ed473fc96d1d51979f302d5a14134a5bcd64e05 (diff) | |
download | cpython-f4009ac6867fd8650336c8b26cc821d62ab6c8b6.tar.gz |
do not leak buffer if mmap is not writable
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/mmapmodule.c | 4 |
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); |