diff options
author | k.h.lai <dlshcbmuipmam@hotmail.com> | 2021-02-03 03:56:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-02 20:56:24 +0100 |
commit | 2072afb72b4b3e9c5dcbcec71d824aeae1b35d19 (patch) | |
tree | 6ec9801012d207a746f4df8a6e0d157919720898 /src | |
parent | f227e40180b2035f33059749b14287478bab374a (diff) | |
download | minetest-2072afb72b4b3e9c5dcbcec71d824aeae1b35d19.tar.gz minetest-2072afb72b4b3e9c5dcbcec71d824aeae1b35d19.tar.bz2 minetest-2072afb72b4b3e9c5dcbcec71d824aeae1b35d19.zip |
Fix memory leak detected by address sanitizer (#10896)
Diffstat (limited to 'src')
-rw-r--r-- | src/client/renderingengine.cpp | 2 | ||||
-rw-r--r-- | src/gui/guiEngine.cpp | 3 | ||||
-rw-r--r-- | src/irrlicht_changes/CGUITTFont.cpp | 4 | ||||
-rw-r--r-- | src/irrlicht_changes/CGUITTFont.h | 1 |
4 files changed, 7 insertions, 3 deletions
diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp index f5aca8f58..99ff8c1ee 100644 --- a/src/client/renderingengine.cpp +++ b/src/client/renderingengine.cpp @@ -153,7 +153,7 @@ RenderingEngine::RenderingEngine(IEventReceiver *receiver) RenderingEngine::~RenderingEngine() { core.reset(); - m_device->drop(); + m_device->closeDevice(); s_singleton = nullptr; } diff --git a/src/gui/guiEngine.cpp b/src/gui/guiEngine.cpp index 6e2c2b053..93463ad70 100644 --- a/src/gui/guiEngine.cpp +++ b/src/gui/guiEngine.cpp @@ -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) @@ -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 diff --git a/src/irrlicht_changes/CGUITTFont.cpp b/src/irrlicht_changes/CGUITTFont.cpp index bd4e700de..0f3368822 100644 --- a/src/irrlicht_changes/CGUITTFont.cpp +++ b/src/irrlicht_changes/CGUITTFont.cpp @@ -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. @@ -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() diff --git a/src/irrlicht_changes/CGUITTFont.h b/src/irrlicht_changes/CGUITTFont.h index 310f74f67..b64e57a45 100644 --- a/src/irrlicht_changes/CGUITTFont.h +++ b/src/irrlicht_changes/CGUITTFont.h @@ -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; |