diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-08-23 11:02:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-23 11:02:19 (GMT) |
commit | 27950d8f761b5c9b80d8ee53d2e6e619bab90180 (patch) | |
tree | c0c278d83ebeee89818bdf8ca39d1c8af54d2a72 /Objects/codeobject.c | |
parent | 04e37850981bceaa31759c2673a945d3713ae7ae (diff) | |
download | cpython-27950d8f761b5c9b80d8ee53d2e6e619bab90180.zip cpython-27950d8f761b5c9b80d8ee53d2e6e619bab90180.tar.gz cpython-27950d8f761b5c9b80d8ee53d2e6e619bab90180.tar.bz2 |
GH-96187: Prevent _PyCode_GetExtra to return garbage for negative indexes (GH-96188)
(cherry picked from commit 16ebae4cd4029205d932751f26c719c6cb8a6e92)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Diffstat (limited to 'Objects/codeobject.c')
-rw-r--r-- | Objects/codeobject.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c index c015143..d7434dd 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -1337,7 +1337,7 @@ _PyCode_GetExtra(PyObject *code, Py_ssize_t index, void **extra) PyCodeObject *o = (PyCodeObject*) code; _PyCodeObjectExtra *co_extra = (_PyCodeObjectExtra*) o->co_extra; - if (co_extra == NULL || co_extra->ce_size <= index) { + if (co_extra == NULL || index < 0 || co_extra->ce_size <= index) { *extra = NULL; return 0; } |