]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45829: Check `__getitem__`'s version for overflow before specializing (GH-30129)
authorBrandt Bucher <brandt@python.org>
Thu, 16 Dec 2021 11:08:20 +0000 (03:08 -0800)
committerGitHub <noreply@github.com>
Thu, 16 Dec 2021 11:08:20 +0000 (11:08 +0000)
* Check __getitem__'s version for overflow.

* Use SPEC_FAIL_OUT_OF_VERSIONS instead

Python/specialize.c

index 7d4387b1639a5d6b905e3ab7b951ea7fab380f3a..730e2f045ebe54b9166bafe2ab201ad5bddd469b 100644 (file)
@@ -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;
         }