From 62a8a0c5223f750e22ee381d3cfbdb718cf1cc93 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 16 Dec 2021 03:08:20 -0800 Subject: bpo-45829: Check `__getitem__`'s version for overflow before specializing (GH-30129) * Check __getitem__'s version for overflow. * Use SPEC_FAIL_OUT_OF_VERSIONS instead --- Python/specialize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/specialize.c b/Python/specialize.c index 7d4387b..730e2f0 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -1187,7 +1187,7 @@ _Py_Specialize_BinarySubscr( assert(cls->tp_version_tag != 0); cache0->version = cls->tp_version_tag; int version = _PyFunction_GetVersionForCurrentState(func); - if (version == 0) { + if (version == 0 || version != (uint16_t)version) { SPECIALIZATION_FAIL(BINARY_SUBSCR, SPEC_FAIL_OUT_OF_VERSIONS); goto fail; } -- cgit v0.12