diff options
author | Ryan C. Gordon <icculus@icculus.org> | 2013-07-20 21:19:20 -0400 |
---|---|---|
committer | Ryan C. Gordon <icculus@icculus.org> | 2013-07-20 21:19:20 -0400 |
commit | f5dc9cbdd4955c89225775af359b8546ec9bdc3c (patch) | |
tree | 8b7bb2e3e4e851e7fc32f6be624d08bdbc6714fc /src | |
parent | 458f6d50dede7b79537242db787f5f6f9ab79439 (diff) |
Don't allocate memory if we're just going to fail when checking parameters.
Diffstat (limited to 'src')
-rw-r--r-- | src/render/SDL_yuv_sw.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index 3319fe4c26..5dd3ff0c70 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -1029,12 +1029,6 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) int i; int CR, CB; - swdata = (SDL_SW_YUVTexture *) SDL_calloc(1, sizeof(*swdata)); - if (!swdata) { - SDL_OutOfMemory(); - return NULL; - } - switch (format) { case SDL_PIXELFORMAT_YV12: case SDL_PIXELFORMAT_IYUV: @@ -1043,11 +1037,16 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) case SDL_PIXELFORMAT_YVYU: break; default: - SDL_SW_DestroyYUVTexture(swdata); SDL_SetError("Unsupported YUV format"); return NULL; } + swdata = (SDL_SW_YUVTexture *) SDL_calloc(1, sizeof(*swdata)); + if (!swdata) { + SDL_OutOfMemory(); + return NULL; + } + swdata->format = format; swdata->target_format = SDL_PIXELFORMAT_UNKNOWN; swdata->w = w; @@ -1095,7 +1094,7 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) swdata->planes[0] = swdata->pixels; break; default: - /* We should never get here (caught above) */ + SDL_assert(0 && "We should never get here (caught above)"); break; } |