Skip to content

Commit

Permalink
Fix segfaults in pixelcopy.c
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcellPerger1 committed Mar 13, 2023
1 parent b176e50 commit 15e0d67
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src_c/pixelcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ array_to_surface(PyObject *self, PyObject *arg)
return NULL;
}
surf = pgSurface_AsSurface(surfobj);
if (!surf)
return RAISE(pgExc_SDLError, "display Surface quit");
format = surf->format;

if (pgObject_GetBuffer(arrayobj, &pg_view, PyBUF_RECORDS_RO)) {
Expand Down Expand Up @@ -776,6 +778,8 @@ surface_to_array(PyObject *self, PyObject *args, PyObject *kwds)
return 0;
}
surf = pgSurface_AsSurface(surfobj);
if (!surf)
return RAISE(pgExc_SDLError, "display Surface quit");

if (pgObject_GetBuffer(arrayobj, &pg_view, PyBUF_RECORDS)) {
pgSurface_Unlock(surfobj);
Expand Down Expand Up @@ -963,6 +967,8 @@ map_array(PyObject *self, PyObject *args)
/* Determine source and destination pixel formats
*/
format = pgSurface_AsSurface(format_surf)->format;
if (!format)
return RAISE(pgExc_SDLError, "display Surface quit");
pix_bytesize = format->BytesPerPixel;
if (tar_itemsize < pix_bytesize) {
PyErr_SetString(PyExc_ValueError,
Expand Down

0 comments on commit 15e0d67

Please sign in to comment.