diff Python/compile.c @ 39446:9f390882a2c3 legacy-trunk

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
author Neal Norwitz <nnorwitz@gmail.com>
date Sat, 12 Aug 2006 01:45:47 +0000
parents 8ef3f8cf90e1
children ed88d6b7c1f9 5e143944770b
line wrap: on
line diff
--- a/Python/compile.c	Sat Aug 12 01:43:40 2006 +0000
+++ b/Python/compile.c	Sat Aug 12 01:45:47 2006 +0000
@@ -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;
 	}