[Python-checkins] python/dist/src/Modules _bisectmodule.c,1.1,1.2

mwh at users.sourceforge.net mwh at users.sourceforge.net
Mon Aug 2 15:24:57 CEST 2004


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7849/Modules

Modified Files:
	_bisectmodule.c 
Log Message:
Any call to insort_{left,right} with a non-list leaked a reference to None
(or to whatever the 'insert' method chose to return).


Index: _bisectmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_bisectmodule.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** _bisectmodule.c	5 Jan 2004 10:13:35 -0000	1.1
--- _bisectmodule.c	2 Aug 2004 13:24:54 -0000	1.2
***************
*** 66,70 ****
  insort_right(PyObject *self, PyObject *args)
  {
! 	PyObject *list, *item;
  	int lo = 0;
  	int hi = -1;
--- 66,70 ----
  insort_right(PyObject *self, PyObject *args)
  {
! 	PyObject *list, *item, *result;
  	int lo = 0;
  	int hi = -1;
***************
*** 81,87 ****
  			return NULL;
  	} else {
! 		if (PyObject_CallMethod(list, "insert", "iO", index, item)
! 			== NULL)
  			return NULL;
  	}
  
--- 81,89 ----
  			return NULL;
  	} else {
! 		result = PyObject_CallMethod(list, "insert", "iO",
! 					     index, item);
! 		if (result == NULL)
  			return NULL;
+ 		Py_DECREF(result);
  	}
  
***************
*** 159,163 ****
  insort_left(PyObject *self, PyObject *args)
  {
! 	PyObject *list, *item;
  	int lo = 0;
  	int hi = -1;
--- 161,165 ----
  insort_left(PyObject *self, PyObject *args)
  {
! 	PyObject *list, *item, *result;
  	int lo = 0;
  	int hi = -1;
***************
*** 174,180 ****
  			return NULL;
  	} else {
! 		if (PyObject_CallMethod(list, "insert", "iO", index, item)
! 			== NULL)
  			return NULL;
  	}
  
--- 176,184 ----
  			return NULL;
  	} else {
! 		result = PyObject_CallMethod(list, "insert", "iO",
! 					     index, item);
! 		if (result == NULL)
  			return NULL;
+ 		Py_DECREF(result);
  	}
  



More information about the Python-checkins mailing list