diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx index 05b97dc8273b..877b94713a8f 100644 --- a/vcl/inc/sft.hxx +++ b/vcl/inc/sft.hxx @@ -720,7 +720,7 @@ constexpr int NUM_TAGS = 17; class VCL_DLLPUBLIC AbstractTrueTypeFont { - char* m_pFileName; + std::unique_ptr m_pFileName; sal_uInt32 m_nGlyphs; sal_uInt32 m_nHorzMetrics; sal_uInt32 m_nVertMetrics; /* if not 0 => font has vertical metrics information */ @@ -735,7 +735,7 @@ public: AbstractTrueTypeFont(const char* fileName = nullptr, const FontCharMapRef xCharMap = nullptr); virtual ~AbstractTrueTypeFont(); - const char* fileName() const { return m_pFileName; } + const char* fileName() const { return m_pFileName.get(); } sal_uInt32 glyphCount() const { return m_nGlyphs; } sal_uInt32 glyphOffset(sal_uInt32 glyphID) const; sal_uInt32 horzMetricCount() const { return m_nHorzMetrics; } diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index a08e475e4ebf..b4932164b98a 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -1114,20 +1114,18 @@ bool withinBounds(sal_uInt32 tdoffset, sal_uInt32 moreoffset, sal_uInt32 len, sa } AbstractTrueTypeFont::AbstractTrueTypeFont(const char* pFileName, const FontCharMapRef xCharMap) - : m_pFileName(nullptr) - , m_nGlyphs(0xFFFFFFFF) + : m_nGlyphs(0xFFFFFFFF) , m_nHorzMetrics(0) , m_nVertMetrics(0) , m_nUnitsPerEm(0) , m_xCharMap(xCharMap) { if (pFileName) - m_pFileName = strdup(pFileName); + m_pFileName.reset(strdup(pFileName)); } AbstractTrueTypeFont::~AbstractTrueTypeFont() { - free(m_pFileName); } TrueTypeFont::TrueTypeFont(const char* pFileName, const FontCharMapRef xCharMap)