summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2021-03-27 03:51:46 (GMT)
committerGitHub <noreply@github.com>2021-03-27 03:51:46 (GMT)
commit11b85abbae8aaa8410b19f358abd7b401881bb1c (patch)
tree1f47d522c0104e5e2cac5ef73dc4d6b51bba1a97 /Objects
parent027b6699276ed8d9f68425697ac89bf61e54e6b9 (diff)
downloadcpython-11b85abbae8aaa8410b19f358abd7b401881bb1c.zip
cpython-11b85abbae8aaa8410b19f358abd7b401881bb1c.tar.gz
cpython-11b85abbae8aaa8410b19f358abd7b401881bb1c.tar.bz2
bpo-43636: Validate the version tag in _PyType_Lookup (GH-25032)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index d1bbbe7..8dafbbf 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -424,7 +424,7 @@ assign_version_tag(struct type_cache *cache, PyTypeObject *type)
if (type->tp_version_tag == 0) {
// Wrap-around or just starting Python - clear the whole cache
type_cache_clear(cache, 1);
- return 1;
+ return 0;
}
bases = type->tp_bases;
@@ -3361,6 +3361,7 @@ _PyType_Lookup(PyTypeObject *type, PyObject *name)
#if MCACHE_STATS
cache->hits++;
#endif
+ assert(_PyType_HasFeature(type, Py_TPFLAGS_VALID_VERSION_TAG));
return entry->value;
}
@@ -3398,6 +3399,7 @@ _PyType_Lookup(PyTypeObject *type, PyObject *name)
cache->misses++;
}
#endif
+ assert(_PyType_HasFeature(type, Py_TPFLAGS_VALID_VERSION_TAG));
Py_SETREF(entry->name, Py_NewRef(name));
}
return res;