]> granicus.if.org Git - python/commitdiff
do not leak buffer if mmap is not writable
authorBenjamin Peterson <benjamin@python.org>
Thu, 6 Oct 2016 06:29:07 +0000 (23:29 -0700)
committerBenjamin Peterson <benjamin@python.org>
Thu, 6 Oct 2016 06:29:07 +0000 (23:29 -0700)
Modules/mmapmodule.c

index 6e2db6134ccb53b18a7134e35d857dafd3e17c15..e01de441bd6609f357f38c46eea9c87f7a38c2b8 100644 (file)
@@ -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);