Fixed potential memory leak in sf::Font
This commit is contained in:
parent
4a300547f3
commit
b5e7e431a5
@ -129,6 +129,7 @@ bool Font::loadFromFile(const std::string& filename)
|
|||||||
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) != 0)
|
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) != 0)
|
||||||
{
|
{
|
||||||
err() << "Failed to load font \"" << filename << "\" (failed to set the Unicode character set)" << std::endl;
|
err() << "Failed to load font \"" << filename << "\" (failed to set the Unicode character set)" << std::endl;
|
||||||
|
FT_Done_Face(face);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,6 +173,7 @@ bool Font::loadFromMemory(const void* data, std::size_t sizeInBytes)
|
|||||||
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) != 0)
|
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) != 0)
|
||||||
{
|
{
|
||||||
err() << "Failed to load font from memory (failed to set the Unicode character set)" << std::endl;
|
err() << "Failed to load font from memory (failed to set the Unicode character set)" << std::endl;
|
||||||
|
FT_Done_Face(face);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,6 +229,7 @@ bool Font::loadFromStream(InputStream& stream)
|
|||||||
if (FT_Open_Face(static_cast<FT_Library>(m_library), &args, 0, &face) != 0)
|
if (FT_Open_Face(static_cast<FT_Library>(m_library), &args, 0, &face) != 0)
|
||||||
{
|
{
|
||||||
err() << "Failed to load font from stream (failed to create the font face)" << std::endl;
|
err() << "Failed to load font from stream (failed to create the font face)" << std::endl;
|
||||||
|
delete rec;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,6 +237,8 @@ bool Font::loadFromStream(InputStream& stream)
|
|||||||
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) != 0)
|
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) != 0)
|
||||||
{
|
{
|
||||||
err() << "Failed to load font from stream (failed to set the Unicode character set)" << std::endl;
|
err() << "Failed to load font from stream (failed to set the Unicode character set)" << std::endl;
|
||||||
|
FT_Done_Face(face);
|
||||||
|
delete rec;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user