From 051c939f8db2f79df2b0cb5645459b08637ddf1e Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Fri, 6 Sep 2013 15:52:45 +0200 Subject: [PATCH] Free SDL surface if 'TexPool::request' throws --- src/bitmap.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bitmap.cpp b/src/bitmap.cpp index 7b65033..e1c9577 100644 --- a/src/bitmap.cpp +++ b/src/bitmap.cpp @@ -143,7 +143,15 @@ Bitmap::Bitmap(const char *filename) p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888); - tex = gState->texPool().request(imgSurf->w, imgSurf->h); + try + { + tex = gState->texPool().request(imgSurf->w, imgSurf->h); + } + catch (const Exception &e) + { + SDL_FreeSurface(imgSurf); + throw e; + } p = new BitmapPrivate; p->tex = tex;