mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	gh-120754: Fix memory leak in FileIO.__init__() (#124225)
Free 'self->stat_atopen' before assigning it, since io.FileIO.__init__() can be called multiple times manually (especially by test_io).
This commit is contained in:
		
							parent
							
								
									ea7fe1fe2e
								
							
						
					
					
						commit
						43cd7aa8cd
					
				
					 1 changed files with 1 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -457,6 +457,7 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
 | 
			
		|||
#endif
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    PyMem_Free(self->stat_atopen);
 | 
			
		||||
    self->stat_atopen = PyMem_New(struct _Py_stat_struct, 1);
 | 
			
		||||
    if (self->stat_atopen == NULL) {
 | 
			
		||||
        PyErr_NoMemory();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue