[Python-checkins] python/dist/src/Objects object.c, 2.209, 2.210 typeobject.c, 2.243, 2.244

mwh at users.sourceforge.net mwh at users.sourceforge.net
Fri Aug 15 07:07:49 EDT 2003


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

Modified Files:
	object.c typeobject.c 
Log Message:
Fix for

[ 784825 ] fix obscure crash in descriptor handling

Should be applied to release23-maint and in all likelyhood 
release22-maint, too.

Certainly doesn't apply to release21-maint.


Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.209
retrieving revision 2.210
diff -C2 -d -r2.209 -r2.210
*** object.c	18 Apr 2003 00:45:58 -0000	2.209
--- object.c	15 Aug 2003 13:07:46 -0000	2.210
***************
*** 1413,1416 ****
--- 1413,1418 ----
  	}
  
+ 	Py_XINCREF(descr);
+ 
  	f = NULL;
  	if (descr != NULL &&
***************
*** 1419,1422 ****
--- 1421,1425 ----
  		if (f != NULL && PyDescr_IsData(descr)) {
  			res = f(descr, obj, (PyObject *)obj->ob_type);
+ 			Py_DECREF(descr);
  			goto done;
  		}
***************
*** 1446,1449 ****
--- 1449,1453 ----
  			if (res != NULL) {
  				Py_INCREF(res);
+ 				Py_XDECREF(descr);
  				goto done;
  			}
***************
*** 1453,1462 ****
  	if (f != NULL) {
  		res = f(descr, obj, (PyObject *)obj->ob_type);
  		goto done;
  	}
  
  	if (descr != NULL) {
- 		Py_INCREF(descr);
  		res = descr;
  		goto done;
  	}
--- 1457,1467 ----
  	if (f != NULL) {
  		res = f(descr, obj, (PyObject *)obj->ob_type);
+ 		Py_DECREF(descr);
  		goto done;
  	}
  
  	if (descr != NULL) {
  		res = descr;
+ 		/* descr was already increfed above */
  		goto done;
  	}

Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.243
retrieving revision 2.244
diff -C2 -d -r2.243 -r2.244
*** typeobject.c	8 Aug 2003 13:57:22 -0000	2.243
--- typeobject.c	15 Aug 2003 13:07:46 -0000	2.244
***************
*** 2011,2014 ****
--- 2011,2015 ----
  					(PyObject *)metatype);
  		}
+ 		Py_INCREF(meta_attribute);
  	}
  
***************
*** 2019,2022 ****
--- 2020,2026 ----
  		/* Implement descriptor functionality, if any */
  		descrgetfunc local_get = attribute->ob_type->tp_descr_get;
+ 
+ 		Py_XDECREF(meta_attribute);
+ 
  		if (local_get != NULL) {
  			/* NULL 2nd argument indicates the descriptor was
***************
*** 2032,2042 ****
  	/* No attribute found in local __dict__ (or bases): use the
  	 * descriptor from the metatype, if any */
! 	if (meta_get != NULL)
! 		return meta_get(meta_attribute, (PyObject *)type,
! 				(PyObject *)metatype);
  
  	/* If an ordinary attribute was found on the metatype, return it now */
  	if (meta_attribute != NULL) {
- 		Py_INCREF(meta_attribute);
  		return meta_attribute;
  	}
--- 2036,2049 ----
  	/* No attribute found in local __dict__ (or bases): use the
  	 * descriptor from the metatype, if any */
! 	if (meta_get != NULL) {
! 		PyObject *res;
! 		res = meta_get(meta_attribute, (PyObject *)type,
! 			       (PyObject *)metatype);
! 		Py_DECREF(meta_attribute);
! 		return res;
! 	}
  
  	/* If an ordinary attribute was found on the metatype, return it now */
  	if (meta_attribute != NULL) {
  		return meta_attribute;
  	}





More information about the Python-checkins mailing list