[Python-checkins] python/dist/src/Objects intobject.c,2.110,2.111

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sat Jun 26 19:22:59 EDT 2004


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

Modified Files:
	intobject.c 
Log Message:
SF bug #980419: int left-shift causes memory leak

Index: intobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v
retrieving revision 2.110
retrieving revision 2.111
diff -C2 -d -r2.110 -r2.111
*** intobject.c	5 Jun 2004 19:49:12 -0000	2.110
--- intobject.c	26 Jun 2004 23:22:57 -0000	2.111
***************
*** 752,755 ****
--- 752,757 ----
  {
  	long a, b, c;
+ 	PyObject *vv, *ww, *result;
+ 
  	CONVERT_TO_LONG(v, a);
  	CONVERT_TO_LONG(w, b);
***************
*** 761,771 ****
  		return int_pos(v);
  	if (b >= LONG_BIT) {
! 		return PyNumber_Lshift(PyLong_FromLong(PyInt_AS_LONG(v)),
! 				       PyLong_FromLong(PyInt_AS_LONG(w)));
  	}
  	c = a << b;
  	if (a != Py_ARITHMETIC_RIGHT_SHIFT(long, c, b)) {
! 		return PyNumber_Lshift(PyLong_FromLong(PyInt_AS_LONG(v)),
! 				       PyLong_FromLong(PyInt_AS_LONG(w)));
  	}
  	return PyInt_FromLong(c);
--- 763,793 ----
  		return int_pos(v);
  	if (b >= LONG_BIT) {
! 		vv = PyLong_FromLong(PyInt_AS_LONG(v));
! 		if (vv == NULL)
! 			return NULL;
! 		ww = PyLong_FromLong(PyInt_AS_LONG(w));
! 		if (ww == NULL) {
! 			Py_DECREF(vv);
! 			return NULL;
! 		}
! 		result = PyNumber_Lshift(vv, ww);
! 		Py_DECREF(vv);
! 		Py_DECREF(ww);
! 		return result;
  	}
  	c = a << b;
  	if (a != Py_ARITHMETIC_RIGHT_SHIFT(long, c, b)) {
! 		vv = PyLong_FromLong(PyInt_AS_LONG(v));
! 		if (vv == NULL)
! 			return NULL;
! 		ww = PyLong_FromLong(PyInt_AS_LONG(w));
! 		if (ww == NULL) {
! 			Py_DECREF(vv);
! 			return NULL;
! 		}
! 		result = PyNumber_Lshift(vv, ww);
! 		Py_DECREF(vv);
! 		Py_DECREF(ww);
! 		return result;
  	}
  	return PyInt_FromLong(c);




More information about the Python-checkins mailing list