[Python-checkins] r52190 - python/branches/release24-maint/Parser/parsetok.c

andrew.kuchling python-checkins at python.org
Thu Oct 5 21:32:53 CEST 2006


Author: andrew.kuchling
Date: Thu Oct 5 21:32:52 2006
New Revision: 52190
Modified:
 python/branches/release24-maint/Parser/parsetok.c
Log:
[Backport r51222 | neal.norwitz -- if you hack the code to set r=NULL, 
 you find that Python does print "MemoryError". There's no traceback
 and no indication of which line of code is responsible, but it's 
 better than a segfault.]
Handle NULL nodes while parsing. I'm not entirely sure this is correct.
There might be something else that needs to be done to setup the error.
Klocwork #295.
Modified: python/branches/release24-maint/Parser/parsetok.c
==============================================================================
--- python/branches/release24-maint/Parser/parsetok.c	(original)
+++ python/branches/release24-maint/Parser/parsetok.c	Thu Oct 5 21:32:52 2006
@@ -197,6 +197,11 @@
 		}
 	} else if (tok->encoding != NULL) {
 		node* r = PyNode_New(encoding_decl);
+		if (!r) {
+			err_ret->error = E_NOMEM;
+			n = NULL;
+			goto done;
+		}
 		r->n_str = tok->encoding;
 		r->n_nchildren = 1;
 		r->n_child = n;
@@ -204,6 +209,7 @@
 		n = r;
 	}
 
+done:
 	PyTokenizer_Free(tok);
 
 	return n;


More information about the Python-checkins mailing list

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