]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-103082: use IS_VALID_OPCODE instead of _PyOpcode_OpName to check if an opcode...
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
Mon, 14 Aug 2023 09:51:50 +0000 (10:51 +0100)
committerGitHub <noreply@github.com>
Mon, 14 Aug 2023 09:51:50 +0000 (10:51 +0100)
Python/instrumentation.c

index 6d11649c07fbe47f2318df6dfc324e69da0e20be..b50e8e26476cd43c65372295daca5b877c5d9d52 100644 (file)
@@ -7,6 +7,7 @@
 #include "pycore_namespace.h"
 #include "pycore_object.h"
 #include "pycore_opcode.h"
+#include "pycore_opcode_metadata.h" // IS_VALID_OPCODE
 #include "pycore_pyerrors.h"
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
 
@@ -437,11 +438,10 @@ dump_instrumentation_data(PyCodeObject *code, int star, FILE*out)
 static bool
 valid_opcode(int opcode)
 {
-    if (opcode > 0 &&
+    if (IS_VALID_OPCODE(opcode) &&
+        opcode != CACHE &&
         opcode != RESERVED &&
-        opcode < 255 &&
-        _PyOpcode_OpName[opcode] &&
-        _PyOpcode_OpName[opcode][0] != '<')
+        opcode < 255)
     {
        return true;
     }