diff --git a/Python/legacy_tracing.c b/Python/legacy_tracing.c index bf65a904de4d211..093a434bdb08281 100644 --- a/Python/legacy_tracing.c +++ b/Python/legacy_tracing.c @@ -353,6 +353,9 @@ sys_trace_line_func( } assert(PyVectorcall_NARGS(nargsf) == 2); int line = PyLong_AsInt(args[1]); + if (line == -1 && PyErr_Occurred()) { + return NULL; + } assert(line >= 0); PyFrameObject *frame = PyEval_GetFrame(); if (frame == NULL) { @@ -379,9 +382,17 @@ sys_trace_jump_func( Py_RETURN_NONE; } assert(PyVectorcall_NARGS(nargsf) == 3); - int from = PyLong_AsInt(args[1])/sizeof(_Py_CODEUNIT); + int from = PyLong_AsInt(args[1]); + if (from == -1 && PyErr_Occurred()) { + return NULL; + } + from /= sizeof(_Py_CODEUNIT); assert(from >= 0); - int to = PyLong_AsInt(args[2])/sizeof(_Py_CODEUNIT); + int to = PyLong_AsInt(args[2]); + if (to == -1 && PyErr_Occurred()) { + return NULL; + } + to /= sizeof(_Py_CODEUNIT); assert(to >= 0); if (to > from) { /* Forward jump */