Skip to content

Commit

Permalink
Fix memory leak detected by address sanitizer (#10896)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adriankhl committed Feb 2, 2021
1 parent f227e40 commit 2072afb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/client/renderingengine.cpp
Expand Up @@ -153,7 +153,7 @@ RenderingEngine::RenderingEngine(IEventReceiver *receiver)
RenderingEngine::~RenderingEngine()
{
core.reset();
m_device->drop();
m_device->closeDevice();
s_singleton = nullptr;
}

Expand Down
3 changes: 1 addition & 2 deletions src/gui/guiEngine.cpp
Expand Up @@ -75,8 +75,6 @@ video::ITexture *MenuTextureSource::getTexture(const std::string &name, u32 *id)
if (name.empty())
return NULL;

m_to_delete.insert(name);

#if ENABLE_GLES
video::ITexture *retval = m_driver->findTexture(name.c_str());
if (retval)
Expand All @@ -88,6 +86,7 @@ video::ITexture *MenuTextureSource::getTexture(const std::string &name, u32 *id)

image = Align2Npot2(image, m_driver);
retval = m_driver->addTexture(name.c_str(), image);
m_to_delete.insert(name);
image->drop();
return retval;
#else
Expand Down
4 changes: 4 additions & 0 deletions src/irrlicht_changes/CGUITTFont.cpp
Expand Up @@ -378,6 +378,7 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia
}

// Store our face.
sguitt_face = face;
tt_face = face->face;

// Store font metrics.
Expand Down Expand Up @@ -436,6 +437,9 @@ CGUITTFont::~CGUITTFont()
// Drop our driver now.
if (Driver)
Driver->drop();

// Destroy sguitt_face after clearing c_faces
delete sguitt_face;
}

void CGUITTFont::reset_images()
Expand Down
1 change: 1 addition & 0 deletions src/irrlicht_changes/CGUITTFont.h
Expand Up @@ -375,6 +375,7 @@ namespace gui
gui::IGUIEnvironment* Environment;
video::IVideoDriver* Driver;
io::path filename;
SGUITTFace* sguitt_face = nullptr;
FT_Face tt_face;
FT_Size_Metrics font_metrics;
FT_Int32 load_flags;
Expand Down

0 comments on commit 2072afb

Please sign in to comment.