Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fixed segfault#3666

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Starbuck5 merged 4 commits intopygame:mainfromoddbookworm:pixelarray-segfault
Jan 15, 2023
Merged

Conversation

@oddbookworm
Copy link
Contributor

Fixes#3665 by raising aValueError if the surface access is after closing thePixelArray

Starbuck5 reacted with thumbs up emoji
Copy link
Contributor

@MatiissMatiiss left a comment

Choose a reason for hiding this comment

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

I'm fairly certain it would be important to add this check to other places where it hasn't been added:

staticPyObject*
_pxarray_get_itemsize(pgPixelArrayObject*self,void*closure)
{
SDL_Surface*surf=pgSurface_AsSurface(self->surface);
returnPyLong_FromLong((long)surf->format->BytesPerPixel);
}

and I'm not sure about this but ifshape also gets set to NULL (even if that doesn't happen, I suppose these should then still check ifself->surface == NULL):

staticPyObject*
_pxarray_get_shape(pgPixelArrayObject*self,void*closure)
{
if (self->shape[1]) {
returnPy_BuildValue("(nn)",self->shape[0],self->shape[1]);
}
returnPy_BuildValue("(n)",self->shape[0]);
}

staticPyObject*
_pxarray_get_strides(pgPixelArrayObject*self,void*closure)
{
if (self->shape[1]) {
returnPy_BuildValue("(nn)",self->strides[0],self->strides[1]);
}
returnPy_BuildValue("(n)",self->strides[0]);
}

staticPyObject*
_pxarray_get_ndim(pgPixelArrayObject*self,void*closure)
{
returnPyLong_FromLong(self->shape[1] ?2L :1L);
}

And I'm fairly certain there are a couple more functions that need this check, perhaps, also inpixelarray_methods.c

@MyreMylar
Copy link
Contributor

MyreMylar commentedJan 14, 2023
edited
Loading

From my testing these are the PixelArray public functions and members that segfault after a first call to.close():

  • .surface
  • .itemsize
  • .close() - a second call to it.
  • transpose()

The others already say:

ValueError: Operation on closed PixelArray.

Or return some valid data. I didn't bother testing all the dunder methods because this is already a fairly dumb thing for a user to be doing.

Copy link
Contributor

@MyreMylarMyreMylar left a comment

Choose a reason for hiding this comment

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

Please add a similar check to clear the other segfaults outlined above.

Copy link
Contributor

@MyreMylarMyreMylar left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@Starbuck5
Copy link
Contributor

This looks reasonable to me, thanks Andrew!

illume pushed a commit that referenced this pull requestApr 30, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

3 more reviewers

@MatiissMatiissMatiiss requested changes

@MyreMylarMyreMylarMyreMylar approved these changes

@Starbuck5Starbuck5Starbuck5 approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

PixelArraypygame.PixelArraysegfault

Projects

None yet

Milestone

2.2.0

Development

Successfully merging this pull request may close these issues.

Segfault inPixelArray when trying to access surface after closing the PixelArray

4 participants

@oddbookworm@MyreMylar@Starbuck5@Matiiss

[8]ページ先頭

©2009-2025 Movatter.jp