diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-05-11 15:30:18 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-05-11 22:01:52 +0200 |
commit | 9e11fb7c464a0ede7686023ccec1761e527d0f81 (patch) | |
tree | 86dd9ac4445372e998f66c3cde331592ffb1004d | |
parent | 95d5fc76defa9cba9e69b9eac4e732c60c516eb0 (diff) |
coverity#1435548 rework to avoid Dereference after null check warning
Change-Id: Ifb0d6af999e4935009669a7f85a77e640ce0eddc
Reviewed-on: https://gerrit.libreoffice.org/54138
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/unx/generic/glyphs/freetype_glyphcache.cxx | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx index b2b1c59f67cf..6476950e5fe5 100644 --- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx +++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx @@ -333,23 +333,22 @@ void FreetypeManager::ClearFontList( ) FreetypeFont* FreetypeManager::CreateFont( const FontSelectPattern& rFSD ) { - FreetypeFontInfo* pFontInfo = nullptr; - // find a FontInfo matching to the font id - sal_IntPtr nFontId = 0; - if (rFSD.mpFontInstance && rFSD.mpFontInstance->GetFontFace()) - nFontId = rFSD.mpFontInstance->GetFontFace()->GetFontId(); + if (!rFSD.mpFontInstance) + return nullptr; + const PhysicalFontFace* pFontFace = rFSD.mpFontInstance->GetFontFace(); + if (!pFontFace) + return nullptr; + + sal_IntPtr nFontId = pFontFace->GetFontId(); FontList::iterator it = maFontList.find(nFontId); - if( it != maFontList.end() ) - pFontInfo = it->second; + FreetypeFontInfo* pFontInfo = it != maFontList.end() ? it->second : nullptr; - if( !pFontInfo ) + if (!pFontInfo) return nullptr; - FreetypeFont* pNew = new FreetypeFont( rFSD, pFontInfo ); - - return pNew; + return new FreetypeFont(rFSD, pFontInfo); } FreetypeFontFace::FreetypeFontFace( FreetypeFontInfo* pFI, const FontAttributes& rDFA ) |