[Python-checkins] python/dist/src/Python compile.c,2.292,2.293

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Mon Sep 15 17:43:19 EDT 2003


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

Modified Files:
	compile.c 
Log Message:
Fix leak discovered in test_new by Michael Hudson.

Will backport to 2.3.1



Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.292
retrieving revision 2.293
diff -C2 -d -r2.292 -r2.293
*** compile.c	28 Aug 2003 14:42:14 -0000	2.292
--- compile.c	15 Sep 2003 21:43:16 -0000	2.293
***************
*** 105,108 ****
--- 105,110 ----
  	int stacksize;
  	int flags;
+ 	PyObject *co;
+ 	PyObject *empty;
  	PyObject *code;
  	PyObject *consts;
***************
*** 128,146 ****
  		return NULL;
  
- 	if (freevars == NULL || cellvars == NULL) {
- 		PyObject *empty = PyTuple_New(0);
- 		if (empty == NULL)
- 		    return NULL;
- 		if (freevars == NULL) {
- 		    freevars = empty;
- 		    Py_INCREF(freevars);
- 		}
- 		if (cellvars == NULL) {
- 		    cellvars = empty;
- 		    Py_INCREF(cellvars);
- 		}
- 		Py_DECREF(empty);
- 	}
- 
  	if (!PyObject_CheckReadBuffer(code)) {
  		PyErr_SetString(PyExc_TypeError,
--- 130,133 ----
***************
*** 149,156 ****
  	}
  
! 	return (PyObject *)PyCode_New(argcount, nlocals, stacksize, flags,
  				      code, consts, names, varnames,
  				      freevars, cellvars, filename, name,
! 				      firstlineno, lnotab); 
  }
  
--- 136,153 ----
  	}
  
! 	empty = PyTuple_New(0);
! 	if (empty == NULL)
! 		return NULL;
! 	if (freevars == NULL)
! 		freevars = empty;
! 	if (cellvars == NULL)
! 		cellvars = empty;
! 
! 	co = (PyObject *) PyCode_New(argcount, nlocals, stacksize, flags,
  				      code, consts, names, varnames,
  				      freevars, cellvars, filename, name,
! 				      firstlineno, lnotab);
! 	Py_DECREF(empty);
! 	return co;
  }
  





More information about the Python-checkins mailing list