Skip to content

Commit

Permalink
Fixed bug 2681 - dereference a NULL pointer dst_fmt in SDL_CreateText…
Browse files Browse the repository at this point in the history
…ureFromSurface function

Nitz

In SDL_CreateTextureFromSurface:

SDL_PixelFormat *dst_fmt;
/* Set up a destination surface for the texture update */
         dst_fmt = SDL_AllocFormat(format);
            temp = SDL_ConvertSurface(surface, dst_fmt, 0);

Here is need of NULL check for dst_fmt because there are chances of NULL return from SDL_AllocFormat(format);
  • Loading branch information
slouken committed Aug 17, 2014
1 parent 984d0fc commit 529ed53
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/render/SDL_render.c
Expand Up @@ -540,6 +540,10 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)

/* Set up a destination surface for the texture update */
dst_fmt = SDL_AllocFormat(format);
if (!dst_fmt) {
SDL_DestroyTexture(texture);
return NULL;
}
temp = SDL_ConvertSurface(surface, dst_fmt, 0);
SDL_FreeFormat(dst_fmt);
if (temp) {
Expand Down

0 comments on commit 529ed53

Please sign in to comment.