Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix reference leaks (needs cleanup)
  • Loading branch information
pablogsal committed Oct 7, 2021
commit 1de88f6f9e96a9145eee4720c0c266c8054b8a28
7 changes: 6 additions & 1 deletion Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -5648,7 +5648,12 @@ _PyEvalFramePushAndInit(PyThreadState *tstate, PyFrameConstructor *con,
PyObject **localsarray = _PyFrame_GetLocalsArray(frame);
if (initialize_locals(tstate, con, localsarray, args, argcount, kwnames, steal_args)) {
if (steal_args) {
for (int i = 0; i < frame->stacktop; i++) {
// If we failed to initialize locals, make sure the caller still own all the
// arguments. Notice that we only need to increase the reference count of the
// *valid* arguments (i.e. the ones that fit into the frame).
PyCodeObject *co = (PyCodeObject*)con->fc_code;
const Py_ssize_t total_args = co->co_argcount + co->co_kwonlyargcount;
for (Py_ssize_t i = 0; i < Py_MIN(argcount, total_args); i++) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GHA is warning:

comparison of integer expressions of different signedness: ‘Py_ssize_t’ {aka ‘long int’} and ‘long unsigned int’ [-Wsign-compare

and

'>': signed/unsigned mismatch [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]
Suggested change
for (Py_ssize_t i = 0; i < Py_MIN(argcount, total_args); i++) {
for (size_t i = 0; i < Py_MIN(argcount, (size_t)total_args); i++) {

Py_XINCREF(frame->localsplus[i]);
Comment thread
pablogsal marked this conversation as resolved.
Outdated
}
}
Expand Down