8000 gh-83004: Clean up refleaks in _decimal initialisation by hauntsaninja · Pull Request #99043 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-83004: Clean up refleaks in _decimal initialisation #99043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
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
undo change to obj
  • Loading branch information
hauntsaninja committed Nov 3, 2022
commit 7b8bea9739a4c434ff666335a974655f86ddf28f
7 changes: 1 addition & 6 deletions Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -6035,12 +6035,7 @@ PyInit__decimal(void)
/* Init mpd_ssize_t constants */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't add a comment there because Github, but CHECK_INT(PyModule_AddObject(m, ssize_cm->name, obj)); for obj on L6038 does not leak obj on failure because its reference count is 1 going into PyModule_AddObject and we Py_CLEAR it on goto error inside CHECK_INT.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you update the PR to add a comment about that?

Copy link
Member

Choose a reason for hiding this comment

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

Ping on this; there's also a merge conflict.

for (ssize_cm = ssize_constants; ssize_cm->name != NULL; ssize_cm++) {
ASSIGN_PTR(obj, PyLong_FromSsize_t(ssize_cm->val));
if (PyModule_AddObjectRef(m, ssize_cm->name, obj) < 0) {
Py_DECREF(obj);
goto error;
}
Py_DECREF(obj);
obj = NULL;
CHECK_INT(PyModule_AddObject(m, ssize_cm->name, obj));
}

/* Init int constants */
Expand Down
0