[Python-checkins] python/dist/src/Objects floatobject.c,2.123,2.124 intobject.c,2.104,2.105 longobject.c,1.160,1.161 unicodeobject.c,2.188,2.189

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
2003年6月28日 13:04:27 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv14359
Modified Files:
	floatobject.c intobject.c longobject.c unicodeobject.c 
Log Message:
SF patch 703666: Several objects don't decref tmp on failure in subtype_new
Submitted By: Christopher A. Craig 
Fillin some missing decrefs.
Index: floatobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v
retrieving revision 2.123
retrieving revision 2.124
diff -C2 -d -r2.123 -r2.124
*** floatobject.c	24 May 2003 20:18:24 -0000	2.123
--- floatobject.c	28 Jun 2003 20:04:24 -0000	2.124
***************
*** 752,757 ****
 	assert(PyFloat_CheckExact(tmp));
 	new = type->tp_alloc(type, 0);
! 	if (new == NULL)
 		return NULL;
 	((PyFloatObject *)new)->ob_fval = ((PyFloatObject *)tmp)->ob_fval;
 	Py_DECREF(tmp);
--- 752,759 ----
 	assert(PyFloat_CheckExact(tmp));
 	new = type->tp_alloc(type, 0);
! 	if (new == NULL) {
! 		Py_DECREF(tmp);
 		return NULL;
+ 	}
 	((PyFloatObject *)new)->ob_fval = ((PyFloatObject *)tmp)->ob_fval;
 	Py_DECREF(tmp);
Index: intobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v
retrieving revision 2.104
retrieving revision 2.105
diff -C2 -d -r2.104 -r2.105
*** intobject.c	17 Apr 2003 18:55:36 -0000	2.104
--- intobject.c	28 Jun 2003 20:04:24 -0000	2.105
***************
*** 959,964 ****
 
 	new = type->tp_alloc(type, 0);
! 	if (new == NULL)
 		return NULL;
 	((PyIntObject *)new)->ob_ival = ival;
 	Py_DECREF(tmp);
--- 959,966 ----
 
 	new = type->tp_alloc(type, 0);
! 	if (new == NULL) {
! 		Py_DECREF(tmp);
 		return NULL;
+ 	}
 	((PyIntObject *)new)->ob_ival = ival;
 	Py_DECREF(tmp);
Index: longobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v
retrieving revision 1.160
retrieving revision 1.161
diff -C2 -d -r1.160 -r1.161
*** longobject.c	5 May 2003 20:39:43 -0000	1.160
--- longobject.c	28 Jun 2003 20:04:25 -0000	1.161
***************
*** 2795,2800 ****
 		n = -n;
 	new = (PyLongObject *)type->tp_alloc(type, n);
! 	if (new == NULL)
 		return NULL;
 	assert(PyLong_Check(new));
 	new->ob_size = tmp->ob_size;
--- 2795,2802 ----
 		n = -n;
 	new = (PyLongObject *)type->tp_alloc(type, n);
! 	if (new == NULL) {
! 		Py_DECREF(tmp);
 		return NULL;
+ 	}
 	assert(PyLong_Check(new));
 	new->ob_size = tmp->ob_size;
Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.188
retrieving revision 2.189
diff -C2 -d -r2.188 -r2.189
*** unicodeobject.c	18 May 2003 12:31:09 -0000	2.188
--- unicodeobject.c	28 Jun 2003 20:04:25 -0000	2.189
***************
*** 6689,6698 ****
 	assert(PyUnicode_Check(tmp));
 	pnew = (PyUnicodeObject *) type->tp_alloc(type, n = tmp->length);
! 	if (pnew == NULL)
 		return NULL;
 	pnew->str = PyMem_NEW(Py_UNICODE, n+1);
 	if (pnew->str == NULL) {
 		_Py_ForgetReference((PyObject *)pnew);
 		PyObject_Del(pnew);
 		return PyErr_NoMemory();
 	}
--- 6689,6701 ----
 	assert(PyUnicode_Check(tmp));
 	pnew = (PyUnicodeObject *) type->tp_alloc(type, n = tmp->length);
! 	if (pnew == NULL) {
! 		Py_DECREF(tmp);
 		return NULL;
+ 	}
 	pnew->str = PyMem_NEW(Py_UNICODE, n+1);
 	if (pnew->str == NULL) {
 		_Py_ForgetReference((PyObject *)pnew);
 		PyObject_Del(pnew);
+ 		Py_DECREF(tmp);
 		return PyErr_NoMemory();
 	}

AltStyle によって変換されたページ (->オリジナル) /