[Python-checkins] r51219 - python/trunk/Python/compile.c

neal.norwitz python-checkins at python.org
Sat Aug 12 03:45:48 CEST 2006


Author: neal.norwitz
Date: Sat Aug 12 03:45:47 2006
New Revision: 51219

Modified:
   python/trunk/Python/compile.c
Log:
Even though _Py_Mangle() isn't truly public anyone can call it and
there was no verification that privateobj was a PyString.  If it wasn't
a string, this could have allowed a NULL pointer to creep in below and crash.

I wonder if this should be PyString_CheckExact?  Must identifiers be strings
or can they be subclasses?

Klocwork #275


Modified: python/trunk/Python/compile.c
==============================================================================
--- python/trunk/Python/compile.c	(original)
+++ python/trunk/Python/compile.c	Sat Aug 12 03:45:47 2006
@@ -204,8 +204,8 @@
 	const char *p, *name = PyString_AsString(ident);
 	char *buffer;
 	size_t nlen, plen;
-	if (privateobj == NULL || name == NULL || name[0] != '_' ||
-            name[1] != '_') {
+	if (privateobj == NULL || !PyString_Check(privateobj) ||
+	    name == NULL || name[0] != '_' || name[1] != '_') {
 		Py_INCREF(ident);
 		return ident;
 	}


More information about the Python-checkins mailing list