Free SDL surface if 'TexPool::request' throws
This commit is contained in:
parent
ef2ed2fb32
commit
051c939f8d
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue