mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	Make ImageFile load images in read-only mode
The code path for mmapped files unnecessarily loaded images in read-write mode and had a long standing FIXME message. This patch uses mmap.ACCESS_READ, which is platform independent to fix this issue.
This commit is contained in:
		
							parent
							
								
									72766b8f4e
								
							
						
					
					
						commit
						a7c58303ca
					
				| 
						 | 
					@ -163,10 +163,9 @@ class ImageFile(Image.Image):
 | 
				
			||||||
                    else:
 | 
					                    else:
 | 
				
			||||||
                        # use mmap, if possible
 | 
					                        # use mmap, if possible
 | 
				
			||||||
                        import mmap
 | 
					                        import mmap
 | 
				
			||||||
                        fp = open(self.filename, "r+")
 | 
					                        fp = open(self.filename, "r")
 | 
				
			||||||
                        size = os.path.getsize(self.filename)
 | 
					                        size = os.path.getsize(self.filename)
 | 
				
			||||||
                        # FIXME: on Unix, use PROT_READ etc
 | 
					                        self.map = mmap.mmap(fp.fileno(), size, access=mmap.ACCESS_READ)
 | 
				
			||||||
                        self.map = mmap.mmap(fp.fileno(), size)
 | 
					 | 
				
			||||||
                        self.im = Image.core.map_buffer(
 | 
					                        self.im = Image.core.map_buffer(
 | 
				
			||||||
                            self.map, self.size, d, e, o, a
 | 
					                            self.map, self.size, d, e, o, a
 | 
				
			||||||
                            )
 | 
					                            )
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user