Skip to content

Commit

Permalink
pythonGH-96187: Prevent _PyCode_GetExtra to return garbage for negati…
Browse files Browse the repository at this point in the history
…ve indexes (pythonGH-96188)
  • Loading branch information
pablogsal authored Aug 23, 2022
1 parent ba7d4b9 commit 16ebae4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed a bug that caused ``_PyCode_GetExtra`` to return garbage for negative
indexes. Patch by Pablo Galindo
2 changes: 1 addition & 1 deletion Objects/codeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,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;
}
Expand Down

0 comments on commit 16ebae4

Please sign in to comment.