From 15f55c045c28e36f92d3599ef1f002c71a0850b0 Mon Sep 17 00:00:00 2001 From: David Capello Date: Sat, 8 Mar 2014 21:34:48 -0300 Subject: [PATCH] wddlock.c: Don't use _al_wd_dirty_lines if it's null Related to issue 359: Program exits unexpectently after minimizing and maximizing too fast. I should find the cause of _al_wd_dirty_lines = NULL, but I wasn't able to reproduce this bug, so at the moment this is the best I can do to avoid a crash. (I suppose that it's related to a temporary invalid state because thread sync issues when the screen/window changes its size.) --- src/allegro/src/win/wddlock.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/allegro/src/win/wddlock.c b/src/allegro/src/win/wddlock.c index 3db957d47..676cecd15 100644 --- a/src/allegro/src/win/wddlock.c +++ b/src/allegro/src/win/wddlock.c @@ -29,6 +29,10 @@ static void update_dirty_lines(BITMAP *bmp) RECT rect; int i; + ASSERT(_al_wd_dirty_lines != NULL); + if (_al_wd_dirty_lines == NULL) + return; + /* The width is always the full bitmap width, because we have no * mechanism for measuring the X range of the update. */ @@ -73,7 +77,10 @@ void gfx_directx_unwrite_bank(BITMAP *bmp) uintptr_t gfx_directx_write_bank_win(BITMAP *bmp, int line) { - _al_wd_dirty_lines[bmp->y_ofs+line] = 1; + ASSERT(_al_wd_dirty_lines != NULL); + + if (_al_wd_dirty_lines != NULL) + _al_wd_dirty_lines[bmp->y_ofs+line] = 1; if (!(bmp->id & BMP_ID_LOCKED)) gfx_directx_autolock(bmp);