mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 15:41:43 +00:00 
			
		
		
		
	Defend against a mutation during comparison
This commit is contained in:
		
							parent
							
								
									1af2bf75a2
								
							
						
					
					
						commit
						b9db9e152f
					
				
					 1 changed files with 5 additions and 0 deletions
				
			
		| 
						 | 
					@ -224,6 +224,11 @@ heappushpop(PyObject *self, PyObject *args)
 | 
				
			||||||
        return item;
 | 
					        return item;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (PyList_GET_SIZE(heap) == 0) {
 | 
				
			||||||
 | 
					        PyErr_SetString(PyExc_IndexError, "index out of range");
 | 
				
			||||||
 | 
					        return NULL;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    returnitem = PyList_GET_ITEM(heap, 0);
 | 
					    returnitem = PyList_GET_ITEM(heap, 0);
 | 
				
			||||||
    Py_INCREF(item);
 | 
					    Py_INCREF(item);
 | 
				
			||||||
    PyList_SET_ITEM(heap, 0, item);
 | 
					    PyList_SET_ITEM(heap, 0, item);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue