Skip to content

Commit e5822e7

Browse files
committed
Check PyLong_AsInt errors in legacy tracing
1 parent dd2faeb commit e5822e7

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

Python/legacy_tracing.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ sys_trace_line_func(
353353
}
354354
assert(PyVectorcall_NARGS(nargsf) == 2);
355355
int line = PyLong_AsInt(args[1]);
356+
if (line == -1 && PyErr_Occurred()) {
357+
return NULL;
358+
}
356359
assert(line >= 0);
357360
PyFrameObject *frame = PyEval_GetFrame();
358361
if (frame == NULL) {
@@ -379,9 +382,17 @@ sys_trace_jump_func(
379382
Py_RETURN_NONE;
380383
}
381384
assert(PyVectorcall_NARGS(nargsf) == 3);
382-
int from = PyLong_AsInt(args[1])/sizeof(_Py_CODEUNIT);
385+
int from = PyLong_AsInt(args[1]);
386+
if (from == -1 && PyErr_Occurred()) {
387+
return NULL;
388+
}
389+
from /= sizeof(_Py_CODEUNIT);
383390
assert(from >= 0);
384-
int to = PyLong_AsInt(args[2])/sizeof(_Py_CODEUNIT);
391+
int to = PyLong_AsInt(args[2]);
392+
if (to == -1 && PyErr_Occurred()) {
393+
return NULL;
394+
}
395+
to /= sizeof(_Py_CODEUNIT);
385396
assert(to >= 0);
386397
if (to > from) {
387398
/* Forward jump */

0 commit comments

Comments
 (0)