[Python-checkins] CVS: python/dist/src/Python compile.c,2.143,2.144

Guido van Rossum python-dev@python.org
Mon, 27 Nov 2000 14:22:39 -0800


Update of /cvsroot/python/python/dist/src/Python
In directory slayer.i.sourceforge.net:/tmp/cvs-serv17324

Modified Files:
	compile.c 
Log Message:
Plug a memory leak in com_import_stmt(): the tuple created to hold the
"..." in "from M import ..." was never DECREFed.  Leak reported by
James Slaughter and nailed by Barry, who also provided an earlier
version of this patch.


Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.143
retrieving revision 2.144
diff -C2 -r2.143 -r2.144
*** compile.c	2000/11/14 20:44:53	2.143
--- compile.c	2000/11/27 22:22:36	2.144
***************
*** 2326,2334 ****
  {
  	int i;
- 	PyObject *tup;
  	REQ(n, import_stmt);
  	/* 'import' dotted_name (',' dotted_name)* |
  	   'from' dotted_name 'import' ('*' | NAME (',' NAME)*) */
  	if (STR(CHILD(n, 0))[0] == 'f') {
  		/* 'from' dotted_name 'import' ... */
  		REQ(CHILD(n, 1), dotted_name);
--- 2326,2334 ----
  {
  	int i;
  	REQ(n, import_stmt);
  	/* 'import' dotted_name (',' dotted_name)* |
  	   'from' dotted_name 'import' ('*' | NAME (',' NAME)*) */
  	if (STR(CHILD(n, 0))[0] == 'f') {
+ 		PyObject *tup;
  		/* 'from' dotted_name 'import' ... */
  		REQ(CHILD(n, 1), dotted_name);
***************
*** 2345,2348 ****
--- 2345,2349 ----
  		}
  		com_addoparg(c, LOAD_CONST, com_addconst(c, tup));
+ 		Py_DECREF(tup);
  		com_push(c, 1);
  		com_addopname(c, IMPORT_NAME, CHILD(n, 1));