# HG changeset patch # User Sam Lantinga # Date 1184536456 0 # Node ID 98e76ba7d5a412a2746dbc500c17dde9de24b126 # Parent 6280c111ee804012ae89cea2a1c31e23844360d6 Merged fix for bug #457 from SDL 1.2 diff -r 6280c111ee80 -r 98e76ba7d5a4 src/SDL_compat.c --- a/src/SDL_compat.c Sun Jul 15 21:53:51 2007 +0000 +++ b/src/SDL_compat.c Sun Jul 15 21:54:16 2007 +0000 @@ -1399,6 +1399,11 @@ { void *pixels; int pitch; + + if (!overlay) { + SDL_SetError("Passed a NULL overlay"); + return -1; + } if (SDL_LockTexture(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch) < 0) { return -1; @@ -1424,12 +1429,19 @@ void SDL_UnlockYUVOverlay(SDL_Overlay * overlay) { + if (!overlay) { + return; + } SDL_UnlockTexture(overlay->hwdata->textureID); } int SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect) { + if (!overlay || !dstrect) { + SDL_SetError("Passed a NULL overlay or dstrect"); + return -1; + } if (SDL_RenderCopy(overlay->hwdata->textureID, NULL, dstrect) < 0) { return -1; } @@ -1440,15 +1452,16 @@ void SDL_FreeYUVOverlay(SDL_Overlay * overlay) { - if (overlay) { - if (overlay->hwdata) { - if (overlay->hwdata->textureID) { - SDL_DestroyTexture(overlay->hwdata->textureID); - } - SDL_free(overlay->hwdata); + if (!overlay) { + return; + } + if (overlay->hwdata) { + if (overlay->hwdata->textureID) { + SDL_DestroyTexture(overlay->hwdata->textureID); } - SDL_free(overlay); + SDL_free(overlay->hwdata); } + SDL_free(overlay); } void