mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 19:34:08 +00:00 
			
		
		
		
	slot_sq_contains(): This leaked a reference to the result of calling
__contains__(). Bugfix candidate.
This commit is contained in:
		
							parent
							
								
									36eb4dfb81
								
							
						
					
					
						commit
						bf9b24464e
					
				
					 1 changed files with 12 additions and 11 deletions
				
			
		| 
						 | 
					@ -4016,10 +4016,11 @@ static int
 | 
				
			||||||
slot_sq_contains(PyObject *self, PyObject *value)
 | 
					slot_sq_contains(PyObject *self, PyObject *value)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	PyObject *func, *res, *args;
 | 
						PyObject *func, *res, *args;
 | 
				
			||||||
 | 
						int result = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	static PyObject *contains_str;
 | 
						static PyObject *contains_str;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	func = lookup_maybe(self, "__contains__", &contains_str);
 | 
						func = lookup_maybe(self, "__contains__", &contains_str);
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (func != NULL) {
 | 
						if (func != NULL) {
 | 
				
			||||||
		args = Py_BuildValue("(O)", value);
 | 
							args = Py_BuildValue("(O)", value);
 | 
				
			||||||
		if (args == NULL)
 | 
							if (args == NULL)
 | 
				
			||||||
| 
						 | 
					@ -4029,16 +4030,16 @@ slot_sq_contains(PyObject *self, PyObject *value)
 | 
				
			||||||
			Py_DECREF(args);
 | 
								Py_DECREF(args);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		Py_DECREF(func);
 | 
							Py_DECREF(func);
 | 
				
			||||||
		if (res == NULL)
 | 
							if (res != NULL) {
 | 
				
			||||||
			return -1;
 | 
								result = PyObject_IsTrue(res);
 | 
				
			||||||
		return PyObject_IsTrue(res);
 | 
								Py_DECREF(res);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else if (PyErr_Occurred())
 | 
						else if (! PyErr_Occurred()) {
 | 
				
			||||||
		return -1;
 | 
							result = _PySequence_IterSearch(self, value,
 | 
				
			||||||
	else {
 | 
											 PY_ITERSEARCH_CONTAINS);
 | 
				
			||||||
		return _PySequence_IterSearch(self, value,
 | 
					 | 
				
			||||||
					      PY_ITERSEARCH_CONTAINS);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SLOT1(slot_sq_inplace_concat, "__iadd__", PyObject *, "O")
 | 
					SLOT1(slot_sq_inplace_concat, "__iadd__", PyObject *, "O")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue