Free SDL surface if 'TexPool::request' throws

This commit is contained in:
Jonas Kulla 2013-09-06 15:52:45 +02:00
parent ef2ed2fb32
commit 051c939f8d
1 changed files with 9 additions and 1 deletions

View File

@ -143,7 +143,15 @@ Bitmap::Bitmap(const char *filename)
p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888); p->ensureFormat(imgSurf, SDL_PIXELFORMAT_ABGR8888);
try
{
tex = gState->texPool().request(imgSurf->w, imgSurf->h); tex = gState->texPool().request(imgSurf->w, imgSurf->h);
}
catch (const Exception &e)
{
SDL_FreeSurface(imgSurf);
throw e;
}
p = new BitmapPrivate; p = new BitmapPrivate;
p->tex = tex; p->tex = tex;