summaryrefslogtreecommitdiff
path: root/Objects/frameobject.c
diff options
context:
space:
mode:
authorAmmar Askar <ammar@ammaraskar.com>2020-06-10 23:31:22 +0000
committerGitHub <noreply@github.com>2020-06-11 00:31:22 +0100
commit3b3b83c965447a8329b34cb4befe6e9908880ee5 (patch)
tree612bf0d51451cc7fefd97c5a45549641e93a86ea /Objects/frameobject.c
parent1642c0ef750f96664a98cadb09301d492098d2fb (diff)
downloadcpython-git-3b3b83c965447a8329b34cb4befe6e9908880ee5.tar.gz
Restrict co_code to be under INT_MAX in codeobject (GH-20628)
Diffstat (limited to 'Objects/frameobject.c')
-rw-r--r--Objects/frameobject.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 0dad42ee7b..6e1cbcfaf6 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -397,9 +397,9 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore
return -1;
}
- int len = Py_SAFE_DOWNCAST(
- PyBytes_GET_SIZE(f->f_code->co_code)/sizeof(_Py_CODEUNIT),
- Py_ssize_t, int);
+ /* PyCode_NewWithPosOnlyArgs limits co_code to be under INT_MAX so this
+ * should never overflow. */
+ int len = (int)(PyBytes_GET_SIZE(f->f_code->co_code) / sizeof(_Py_CODEUNIT));
int *lines = marklines(f->f_code, len);
if (lines == NULL) {
return -1;