Skip to content

Commit 74fc87a

Browse files
committed
Fix memory leak
1 parent e2305c3 commit 74fc87a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src_c/surface.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,7 @@ surf_convert(pgSurfaceObject *self, PyObject *args)
14571457
/* will be updated later, initialize to make static analyzer happy
14581458
*/
14591459
int bpp = 0;
1460+
SDL_Palette *palette = SDL_AllocPalette(default_palette_size);
14601461
SDL_PixelFormat format;
14611462

14621463
memcpy(&format, surf->format, sizeof(format));
@@ -1566,15 +1567,14 @@ surf_convert(pgSurfaceObject *self, PyObject *args)
15661567
/* Give the surface something other than an all white
15671568
* palette.
15681569
*/
1569-
SDL_Palette *palette =
1570-
SDL_AllocPalette(default_palette_size);
15711570
SDL_SetPaletteColors(palette, default_palette_colors, 0,
15721571
default_palette_size);
15731572
format.palette = palette;
15741573
}
15751574
}
15761575
newsurf = SDL_ConvertSurface(surf, &format, 0);
15771576
SDL_SetSurfaceBlendMode(newsurf, SDL_BLENDMODE_NONE);
1577+
SDL_FreePalette(palette);
15781578
}
15791579
}
15801580
else {

0 commit comments

Comments
 (0)