Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Fix CNullDriver::removeTexture() segfault
Browse files Browse the repository at this point in the history
`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 7298b46
  • Loading branch information
sfan5 committed Sep 13, 2023
1 parent f9d7a63 commit 679dfd3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions source/Irrlicht/CNullDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,16 @@ void CNullDriver::removeTexture(ITexture* texture)
SSurface s;
s.Surface = texture;

s32 index = Textures.binary_search(s);
if (index != -1) {
texture->drop();
Textures.erase(index);
s32 last;
s32 first = Textures.binary_search_multi(s, last);
if (first == -1)
return;
for (u32 i = first; i <= (u32)last; i++) {
if (Textures[i].Surface == texture) {
texture->drop();
Textures.erase(i);
return;
}
}
}

Expand Down

0 comments on commit 679dfd3

Please sign in to comment.