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 | 3776836f675f3d52b21713a45460f09a03af15df (patch) | |
tree | 923064bbeb013d3d1467db2c593fd3bac050ede6 | |
parent | 4c8b2cd12650a05d87f3cef7f457bfddaf79c0e0 (diff) | |
download | cpython-git-3776836f675f3d52b21713a45460f09a03af15df.tar.gz |
do not leak buffer if mmap is not writable
-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); |