src/render/SDL_yuv_sw.c
changeset 8643 a0500498afee
parent 8149 681eb46b8ac4
child 9619 b94b6d0bff0f
     1.1 --- a/src/render/SDL_yuv_sw.c	Wed Mar 19 16:55:38 2014 -0400
     1.2 +++ b/src/render/SDL_yuv_sw.c	Wed Mar 19 18:25:21 2014 -0400
     1.3 @@ -1274,11 +1274,16 @@
     1.4                      Uint32 target_format, int w, int h, void *pixels,
     1.5                      int pitch)
     1.6  {
     1.7 +    const int targetbpp = SDL_BYTESPERPIXEL(target_format);
     1.8      int stretch;
     1.9      int scale_2x;
    1.10      Uint8 *lum, *Cr, *Cb;
    1.11      int mod;
    1.12  
    1.13 +    if (targetbpp == 0) {
    1.14 +        return SDL_SetError("Invalid target pixel format");
    1.15 +    }
    1.16 +
    1.17      /* Make sure we're set up to display in the desired format */
    1.18      if (target_format != swdata->target_format) {
    1.19          if (SDL_SW_SetupYUVDisplay(swdata, target_format) < 0) {
    1.20 @@ -1366,7 +1371,7 @@
    1.21      default:
    1.22          return SDL_SetError("Unsupported YUV format in copy");
    1.23      }
    1.24 -    mod = (pitch / SDL_BYTESPERPIXEL(target_format));
    1.25 +    mod = (pitch / targetbpp);
    1.26  
    1.27      if (scale_2x) {
    1.28          mod -= (swdata->w * 2);