Skip to content

Commit 2072afb

Browse files
authoredFeb 2, 2021
Fix memory leak detected by address sanitizer (#10896)
1 parent f227e40 commit 2072afb

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed
 

‎src/client/renderingengine.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ RenderingEngine::RenderingEngine(IEventReceiver *receiver)
153153
RenderingEngine::~RenderingEngine()
154154
{
155155
core.reset();
156-
m_device->drop();
156+
m_device->closeDevice();
157157
s_singleton = nullptr;
158158
}
159159

‎src/gui/guiEngine.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ video::ITexture *MenuTextureSource::getTexture(const std::string &name, u32 *id)
7575
if (name.empty())
7676
return NULL;
7777

78-
m_to_delete.insert(name);
79-
8078
#if ENABLE_GLES
8179
video::ITexture *retval = m_driver->findTexture(name.c_str());
8280
if (retval)
@@ -88,6 +86,7 @@ video::ITexture *MenuTextureSource::getTexture(const std::string &name, u32 *id)
8886

8987
image = Align2Npot2(image, m_driver);
9088
retval = m_driver->addTexture(name.c_str(), image);
89+
m_to_delete.insert(name);
9190
image->drop();
9291
return retval;
9392
#else

‎src/irrlicht_changes/CGUITTFont.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia
378378
}
379379

380380
// Store our face.
381+
sguitt_face = face;
381382
tt_face = face->face;
382383

383384
// Store font metrics.
@@ -436,6 +437,9 @@ CGUITTFont::~CGUITTFont()
436437
// Drop our driver now.
437438
if (Driver)
438439
Driver->drop();
440+
441+
// Destroy sguitt_face after clearing c_faces
442+
delete sguitt_face;
439443
}
440444

441445
void CGUITTFont::reset_images()

‎src/irrlicht_changes/CGUITTFont.h

+1
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ namespace gui
375375
gui::IGUIEnvironment* Environment;
376376
video::IVideoDriver* Driver;
377377
io::path filename;
378+
SGUITTFace* sguitt_face = nullptr;
378379
FT_Face tt_face;
379380
FT_Size_Metrics font_metrics;
380381
FT_Int32 load_flags;

0 commit comments

Comments
 (0)
Please sign in to comment.