Fix use-after-free when switching blitters in SDL and Win32 modes.
This mostly occurs when disabling pallete animation when fast-forward is enabled.
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "clear_map.h"
|
||||
#include "clear_func.h"
|
||||
#include "tree_map.h"
|
||||
#include "scope.h"
|
||||
#include "table/tree_land.h"
|
||||
#include "blitter/32bpp_base.hpp"
|
||||
|
||||
@@ -331,6 +332,11 @@ static bool SwitchNewGRFBlitter()
|
||||
const bool animation_wanted = HasBit(_display_opt, DO_FULL_ANIMATION);
|
||||
const char *cur_blitter = BlitterFactory::GetCurrentBlitter()->GetName();
|
||||
|
||||
VideoDriver::GetInstance()->AcquireBlitterLock();
|
||||
auto guard = scope_guard([&]() {
|
||||
VideoDriver::GetInstance()->ReleaseBlitterLock();
|
||||
});
|
||||
|
||||
for (uint i = 0; i < lengthof(replacement_blitters); i++) {
|
||||
if (animation_wanted && (replacement_blitters[i].animation == 0)) continue;
|
||||
if (!animation_wanted && (replacement_blitters[i].animation == 1)) continue;
|
||||
|
Reference in New Issue
Block a user