Skip to content

Commit

Permalink
Fixed bug #457
Browse files Browse the repository at this point in the history
Don't crash if passed a NULL overlay.  The app crashes anyway, since
it's not checking the return value of the create call, but at least it's
not crashing in SDL anymore. :)
  • Loading branch information
slouken committed Jul 15, 2007
1 parent eff5e03 commit 7e366d8
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/video/SDL_yuv.c
Expand Up @@ -65,11 +65,18 @@ SDL_Overlay *SDL_CreateYUVOverlay(int w, int h, Uint32 format,

int SDL_LockYUVOverlay(SDL_Overlay *overlay)
{
if ( overlay == NULL ) {
SDL_SetError("Passed NULL overlay");
return -1;
}
return overlay->hwfuncs->Lock(current_video, overlay);
}

void SDL_UnlockYUVOverlay(SDL_Overlay *overlay)
{
if ( overlay == NULL ) {
return;
}
overlay->hwfuncs->Unlock(current_video, overlay);
}

Expand All @@ -79,6 +86,11 @@ int SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect)
int srcx, srcy, srcw, srch;
int dstx, dsty, dstw, dsth;

if ( overlay == NULL || dstrect == NULL ) {
SDL_SetError("Passed NULL overlay or dstrect");
return -1;
}

/* Clip the rectangle to the screen area */
srcx = 0;
srcy = 0;
Expand Down Expand Up @@ -128,10 +140,11 @@ int SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect)

void SDL_FreeYUVOverlay(SDL_Overlay *overlay)
{
if ( overlay ) {
if ( overlay->hwfuncs ) {
overlay->hwfuncs->FreeHW(current_video, overlay);
}
SDL_free(overlay);
if ( overlay == NULL ) {
return;
}
if ( overlay->hwfuncs ) {
overlay->hwfuncs->FreeHW(current_video, overlay);
}
SDL_free(overlay);
}

0 comments on commit 7e366d8

Please sign in to comment.