mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
GH-96187: Prevent _PyCode_GetExtra to return garbage for negative indexes (GH-96188)
This commit is contained in:
parent
ba7d4b9dc1
commit
16ebae4cd4
2 changed files with 3 additions and 1 deletions
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fixed a bug that caused ``_PyCode_GetExtra`` to return garbage for negative
|
||||||
|
indexes. Patch by Pablo Galindo
|
||||||
|
|
@ -1339,7 +1339,7 @@ _PyCode_GetExtra(PyObject *code, Py_ssize_t index, void **extra)
|
||||||
PyCodeObject *o = (PyCodeObject*) code;
|
PyCodeObject *o = (PyCodeObject*) code;
|
||||||
_PyCodeObjectExtra *co_extra = (_PyCodeObjectExtra*) o->co_extra;
|
_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;
|
*extra = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue