From 1ec0dfb5e113b986f002ab1efdbad938be1025fe Mon Sep 17 00:00:00 2001 From: Roland van Laar Date: Tue, 18 Oct 2022 09:27:01 +0200 Subject: [PATCH] DIRECTOR: Fix segfault when loading broken pic Handle loadStream returning false when the pic doesn't confirm. In this case a 'DIB ' with a headersize not matching 40. Observed happening in: - Fujitsu fm TOWNS Super TECHNOLOGY DEMO - KUZIRA.MMM from PINGU --- engines/director/cast.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp index d2bd6cce9c8..02f92874db8 100644 --- a/engines/director/cast.cpp +++ b/engines/director/cast.cpp @@ -721,13 +721,13 @@ void Cast::loadBitmapData(int key, BitmapCastMember *bitmapCast) { break; } - if (!img) { + if (!img || !img->loadStream(*pic)) { + warning("Cast::loadBitmapData():: Unable to load id: %d", imgId); delete pic; + delete img; return; } - img->loadStream(*pic); - bitmapCast->_img = img; const Graphics::Surface *surf = img->getSurface(); bitmapCast->_size = surf->pitch * surf->h + img->getPaletteColorCount() * 3;