Skip to content

ceval.c: missing PyErr_NoMemory + PyEval_GetLocals NULL #153205

Description

@aisk

Bug report

Bug description:

Original gist: https://gist.githubusercontent.com/devdanzin/55ed5cf0d452eb6ce881e7a8fad30ddb/raw/aec57efe5d45a6995757b60970173d5dca92f188/ceval_stackref_oom.md

ceval.c: Missing PyErr_NoMemory in _PyObjectArray_FromStackRefArray + PyEval_GetLocals NULL deref

Summary

  1. _PyObjectArray_FromStackRefArray (line 1112): PyMem_Malloc returns NULL without exception. Affects ~10 vectorcall functions → SystemError.
  2. PyEval_GetLocals (line 2622): _PyFrame_GetFrameObject can return NULL, immediately dereferenced → segfault.

Fix

  1. Add PyErr_NoMemory() after PyMem_Malloc failure.
  2. Add NULL check after _PyFrame_GetFrameObject.

But the second _PyFrame_GetFrameObject issue is already resolved by #146124

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions