Merged fix for bug #457 from SDL 1.2
authorSam Lantinga <slouken@libsdl.org>
Sun, 15 Jul 2007 21:54:16 +0000
changeset 220298e76ba7d5a4
parent 2201 6280c111ee80
child 2203 fca1cdc673b2
Merged fix for bug #457 from SDL 1.2
src/SDL_compat.c
     1.1 --- a/src/SDL_compat.c	Sun Jul 15 21:53:51 2007 +0000
     1.2 +++ b/src/SDL_compat.c	Sun Jul 15 21:54:16 2007 +0000
     1.3 @@ -1399,6 +1399,11 @@
     1.4  {
     1.5      void *pixels;
     1.6      int pitch;
     1.7 +
     1.8 +    if (!overlay) {
     1.9 +        SDL_SetError("Passed a NULL overlay");
    1.10 +        return -1;
    1.11 +    }
    1.12      if (SDL_LockTexture(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch)
    1.13          < 0) {
    1.14          return -1;
    1.15 @@ -1424,12 +1429,19 @@
    1.16  void
    1.17  SDL_UnlockYUVOverlay(SDL_Overlay * overlay)
    1.18  {
    1.19 +    if (!overlay) {
    1.20 +        return;
    1.21 +    }
    1.22      SDL_UnlockTexture(overlay->hwdata->textureID);
    1.23  }
    1.24  
    1.25  int
    1.26  SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect)
    1.27  {
    1.28 +    if (!overlay || !dstrect) {
    1.29 +        SDL_SetError("Passed a NULL overlay or dstrect");
    1.30 +        return -1;
    1.31 +    }
    1.32      if (SDL_RenderCopy(overlay->hwdata->textureID, NULL, dstrect) < 0) {
    1.33          return -1;
    1.34      }
    1.35 @@ -1440,15 +1452,16 @@
    1.36  void
    1.37  SDL_FreeYUVOverlay(SDL_Overlay * overlay)
    1.38  {
    1.39 -    if (overlay) {
    1.40 -        if (overlay->hwdata) {
    1.41 -            if (overlay->hwdata->textureID) {
    1.42 -                SDL_DestroyTexture(overlay->hwdata->textureID);
    1.43 -            }
    1.44 -            SDL_free(overlay->hwdata);
    1.45 +    if (!overlay) {
    1.46 +        return;
    1.47 +    }
    1.48 +    if (overlay->hwdata) {
    1.49 +        if (overlay->hwdata->textureID) {
    1.50 +            SDL_DestroyTexture(overlay->hwdata->textureID);
    1.51          }
    1.52 -        SDL_free(overlay);
    1.53 +        SDL_free(overlay->hwdata);
    1.54      }
    1.55 +    SDL_free(overlay);
    1.56  }
    1.57  
    1.58  void