mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	Release buffer if function returns prematurely
This commit is contained in:
		
							parent
							
								
									4b626ea14a
								
							
						
					
					
						commit
						e7ce609889
					
				| 
						 | 
					@ -355,17 +355,21 @@ PyImaging_MapBuffer(PyObject* self, PyObject* args)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (view.len < 0) {
 | 
					    if (view.len < 0) {
 | 
				
			||||||
        PyErr_SetString(PyExc_ValueError, "buffer has negative size");
 | 
					        PyErr_SetString(PyExc_ValueError, "buffer has negative size");
 | 
				
			||||||
 | 
					        PyBuffer_Release(&view);
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (offset + size > view.len) {
 | 
					    if (offset + size > view.len) {
 | 
				
			||||||
        PyErr_SetString(PyExc_ValueError, "buffer is not large enough");
 | 
					        PyErr_SetString(PyExc_ValueError, "buffer is not large enough");
 | 
				
			||||||
 | 
					        PyBuffer_Release(&view);
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    im = ImagingNewPrologueSubtype(
 | 
					    im = ImagingNewPrologueSubtype(
 | 
				
			||||||
        mode, xsize, ysize, sizeof(ImagingBufferInstance));
 | 
					        mode, xsize, ysize, sizeof(ImagingBufferInstance));
 | 
				
			||||||
    if (!im)
 | 
					    if (!im) {
 | 
				
			||||||
 | 
					        PyBuffer_Release(&view);
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* setup file pointers */
 | 
					    /* setup file pointers */
 | 
				
			||||||
    if (ystep > 0)
 | 
					    if (ystep > 0)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user