mirror of
https://github.com/minetest/irrlicht.git
synced 2024-12-26 02:30:31 +01:00
Fix CNullDriver::removeTexture() segfault
`Textures` is not an one-to-one mapping.
Minetest still crashes with this commit but that's because
it attempts to double-free a texture.
broken by 7298b46504
This commit is contained in:
parent
f9d7a632f5
commit
679dfd3343
@ -286,10 +286,16 @@ void CNullDriver::removeTexture(ITexture* texture)
|
|||||||
SSurface s;
|
SSurface s;
|
||||||
s.Surface = texture;
|
s.Surface = texture;
|
||||||
|
|
||||||
s32 index = Textures.binary_search(s);
|
s32 last;
|
||||||
if (index != -1) {
|
s32 first = Textures.binary_search_multi(s, last);
|
||||||
texture->drop();
|
if (first == -1)
|
||||||
Textures.erase(index);
|
return;
|
||||||
|
for (u32 i = first; i <= (u32)last; i++) {
|
||||||
|
if (Textures[i].Surface == texture) {
|
||||||
|
texture->drop();
|
||||||
|
Textures.erase(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user