Skip to content
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

Fix some surface refcounting issues in display #2997

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ankith26
Copy link
Member

In get_surface, a strong reference was being incref-ed before being returned (double incref issue)

In set_mode there was a decref followed by an incref, which is technically wrong (I suppose in practice it doesn't create an issue, but I fixed it anyways)

@ankith26 ankith26 requested a review from a team as a code owner July 15, 2024 17:48
@damusss damusss added display pygame.display bugfix PR that fixes bug labels Jul 21, 2024
Copy link
Contributor

@damusss damusss left a comment

Choose a reason for hiding this comment

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

Alright now that I understand it the bugfix makes sense, so it LGTM :)

@MyreMylar
Copy link
Member

In set_mode there was a decref followed by an incref, which is technically wrong (I suppose in practice it doesn't create an issue, but I fixed it anyways)

What about the return here:

pygame-ce/src_c/display.c

Lines 1333 to 1339 in f5f850a

if (depth != 0 && PG_SURF_BitsPerPixel(surface->surf) != depth) {
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"The depth argument is deprecated, and is ignored",
1)) {
return NULL;
}
}

Won't removing the decref cause a leak if it returns NULL?

@ankith26 ankith26 marked this pull request as draft August 14, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix PR that fixes bug display pygame.display
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants