[Python-checkins] python/dist/src/Python bltinmodule.c,2.294,2.295

doerwalter at users.sourceforge.net doerwalter at users.sourceforge.net
Mon Aug 18 12:28:47 EDT 2003


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv16936/Python

Modified Files:
	bltinmodule.c 
Log Message:
Fix a crash: when sq_item failed the code continued blindly and used the
NULL pointer. (Detected by Michael Hudson, patch provided by Neal Norwitz).

Fix refcounting leak in filtertuple().


Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.294
retrieving revision 2.295
diff -C2 -d -r2.294 -r2.295
*** bltinmodule.c	14 Aug 2003 20:37:34 -0000	2.294
--- bltinmodule.c	18 Aug 2003 18:28:45 -0000	2.295
***************
*** 2175,2178 ****
--- 2175,2180 ----
  		    tuple->ob_type->tp_as_sequence->sq_item) {
  			item = tuple->ob_type->tp_as_sequence->sq_item(tuple, i);
+ 			if (item == NULL)
+ 				goto Fail_1;
  		} else {
  			PyErr_SetString(PyExc_TypeError, "filter(): unsubscriptable tuple");
***************
*** 2185,2202 ****
  		else {
  			PyObject *arg = Py_BuildValue("(O)", item);
! 			if (arg == NULL)
  				goto Fail_1;
  			good = PyEval_CallObject(func, arg);
  			Py_DECREF(arg);
! 			if (good == NULL)
  				goto Fail_1;
  		}
  		ok = PyObject_IsTrue(good);
  		Py_DECREF(good);
  		if (ok) {
- 			Py_INCREF(item);
  			if (PyTuple_SetItem(result, j++, item) < 0)
  				goto Fail_1;
  		}
  	}
  
--- 2187,2209 ----
  		else {
  			PyObject *arg = Py_BuildValue("(O)", item);
! 			if (arg == NULL) {
! 				Py_DECREF(item);
  				goto Fail_1;
+ 			}
  			good = PyEval_CallObject(func, arg);
  			Py_DECREF(arg);
! 			if (good == NULL) {
! 				Py_DECREF(item);
  				goto Fail_1;
+ 			}
  		}
  		ok = PyObject_IsTrue(good);
  		Py_DECREF(good);
  		if (ok) {
  			if (PyTuple_SetItem(result, j++, item) < 0)
  				goto Fail_1;
  		}
+ 		else
+ 			Py_DECREF(item);
  	}
  





More information about the Python-checkins mailing list