diff options
author | Benjamin Peterson <benjamin@python.org> | 2016-10-06 06:29:07 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2016-10-06 06:29:07 (GMT) |
commit | 3776836f675f3d52b21713a45460f09a03af15df (patch) | |
tree | 923064bbeb013d3d1467db2c593fd3bac050ede6 /Modules/mmapmodule.c | |
parent | 4c8b2cd12650a05d87f3cef7f457bfddaf79c0e0 (diff) | |
download | cpython-3776836f675f3d52b21713a45460f09a03af15df.zip cpython-3776836f675f3d52b21713a45460f09a03af15df.tar.gz cpython-3776836f675f3d52b21713a45460f09a03af15df.tar.bz2 |
do not leak buffer if mmap is not writable
Diffstat (limited to 'Modules/mmapmodule.c')
-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 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); |