vcl/inc/fontsubset.hxx                      |    4 ++--
 vcl/inc/ppdparser.hxx                       |    2 +-
 vcl/inc/strhelper.hxx                       |    2 +-
 vcl/inc/unx/fontmanager.hxx                 |    2 +-
 vcl/source/fontsubset/cff.cxx               |    2 +-
 vcl/source/fontsubset/fontsubset.cxx        |    9 ++-------
 vcl/source/fontsubset/sft.cxx               |    2 +-
 vcl/source/helper/strhelper.cxx             |    8 ++++----
 vcl/unx/generic/fontmanager/fontmanager.cxx |   23 +++++++----------------
 vcl/unx/generic/printer/ppdparser.cxx       |   12 +++---------
 vcl/unx/gtk3/gtkinst.cxx                    |    4 +---
 11 files changed, 24 insertions(+), 46 deletions(-)

New commits:
commit b209d17236778b5bd2ca8f519166e75447ed9117
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Apr 19 12:37:28 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Apr 19 21:27:11 2024 +0200

    mpReqFontName is potentially pointing to freed memory
    
    since we assign it from a temporary OString.
    
    No idea why this hasn't caused a problem already.
    
    Change-Id: I5480fb2ab5d1e07212ad804f99223946abf5a6c9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166297
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/inc/fontsubset.hxx b/vcl/inc/fontsubset.hxx
index 01bd67f4bff8..490d4839f711 100644
--- a/vcl/inc/fontsubset.hxx
+++ b/vcl/inc/fontsubset.hxx
@@ -77,7 +77,7 @@ private:
     // subset-request details
     FontType                mnReqFontTypeMask;  ///< allowed subset-target 
font types
     SvStream*               mpOutFile;
-    const char*             mpReqFontName;
+    OString                 maReqFontName;
     const sal_GlyphId*      mpReqGlyphIds;
     const sal_uInt8*        mpReqEncodedIds;
     int                     mnReqGlyphCount;
diff --git a/vcl/source/fontsubset/cff.cxx b/vcl/source/fontsubset/cff.cxx
index 2021a6a44d71..384556458b4d 100644
--- a/vcl/source/fontsubset/cff.cxx
+++ b/vcl/source/fontsubset/cff.cxx
@@ -2615,7 +2615,7 @@ bool FontSubsetInfo::CreateFontSubsetFromCff()
     // TODO: also support CFF->CFF subsetting (when PDF-export and PS-printing 
need it)
     const bool bPfbSubset(mnReqFontTypeMask & FontType::TYPE1_PFB);
     Type1Emitter aType1Emitter( mpOutFile, bPfbSubset);
-    aType1Emitter.setSubsetName( mpReqFontName);
+    aType1Emitter.setSubsetName( maReqFontName.getStr() );
     aCff.emitAsType1( aType1Emitter,
         mpReqGlyphIds, mpReqEncodedIds,
         mnReqGlyphCount, *this);
diff --git a/vcl/source/fontsubset/fontsubset.cxx 
b/vcl/source/fontsubset/fontsubset.cxx
index d0e05058f967..0fab8bfbf087 100644
--- a/vcl/source/fontsubset/fontsubset.cxx
+++ b/vcl/source/fontsubset/fontsubset.cxx
@@ -35,7 +35,6 @@ FontSubsetInfo::FontSubsetInfo()
     , meInFontType( FontType::NO_FONT)
     , mnReqFontTypeMask( FontType::NO_FONT )
     , mpOutFile(nullptr)
-    , mpReqFontName(nullptr)
     , mpReqGlyphIds(nullptr)
     , mpReqEncodedIds(nullptr)
     , mnReqGlyphCount(0)
@@ -67,9 +66,7 @@ bool FontSubsetInfo::CreateFontSubset(
     mpReqGlyphIds   = pReqGlyphIds;
     mpReqEncodedIds = pReqEncodedIds;
     mnReqGlyphCount = nReqGlyphCount;
-
-    OString aPSName = m_aPSName.toUtf8();
-    mpReqFontName = aPSName.getStr();
+    maReqFontName = m_aPSName.toUtf8();
 
     // TODO: move the glyphid/encid/notdef reshuffling from the callers to here
 
commit 598ff4e2433a419a432fd54ed5dac560663ec107
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Apr 19 12:35:06 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Apr 19 21:27:01 2024 +0200

    loplugin:constantparam in vcl
    
    Change-Id: Ifab93e642773bcbf3801cee36bf3db66446febec
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166295
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/inc/fontsubset.hxx b/vcl/inc/fontsubset.hxx
index fbe648940d0c..01bd67f4bff8 100644
--- a/vcl/inc/fontsubset.hxx
+++ b/vcl/inc/fontsubset.hxx
@@ -54,7 +54,7 @@ public:
                     const unsigned char* pFontBytes, int nByteLength );
 
     SAL_DLLPRIVATE bool CreateFontSubset( FontType nOutFontTypeMask,
-                    SvStream* pOutFile, const char* pOutFontName,
+                    SvStream* pOutFile,
                     const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncodedIds,
                     int nReqGlyphCount);
 
diff --git a/vcl/inc/ppdparser.hxx b/vcl/inc/ppdparser.hxx
index cbc1b94b4ea8..732e9e550166 100644
--- a/vcl/inc/ppdparser.hxx
+++ b/vcl/inc/ppdparser.hxx
@@ -172,7 +172,7 @@ private:
     static void initPPDFiles(PPDCache &rPPDCache);
     static OUString getPPDFile( const OUString& rFile );
 
-    OUString        matchPaperImpl(int nWidth, int nHeight, bool bDontSwap = 
false, psp::orientation* pOrientation = nullptr) const;
+    OUString        matchPaperImpl(int nWidth, int nHeight, psp::orientation* 
pOrientation) const;
 
 public:
     ~PPDParser();
diff --git a/vcl/inc/strhelper.hxx b/vcl/inc/strhelper.hxx
index e8f085864139..1a48e2742ece 100644
--- a/vcl/inc/strhelper.hxx
+++ b/vcl/inc/strhelper.hxx
@@ -32,7 +32,7 @@ namespace psp
     int GetCommandLineTokenCount(const OUString&);
     // returns number of tokens (zero if empty or whitespace only)
 
-    OUString WhitespaceToSpace( std::u16string_view, bool bProtect = true );
+    OUString WhitespaceToSpace(std::u16string_view);
     OString WhitespaceToSpace(std::string_view);
     // returns a string with multiple adjacent occurrences of whitespace
     // converted to a single space. if bProtect is sal_True (nonzero), then
diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx
index 393975d9fa19..450f711338e1 100644
--- a/vcl/inc/unx/fontmanager.hxx
+++ b/vcl/inc/unx/fontmanager.hxx
@@ -87,7 +87,7 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
 
     OString getFontFile(const PrintFont& rFont) const;
 
-    std::vector<PrintFont> analyzeFontFile(int nDirID, const OString& 
rFileName, const char *pFormat=nullptr) const;
+    std::vector<PrintFont> analyzeFontFile(int nDirID, const OString& 
rFileName) const;
     bool analyzeSfntFile(PrintFont& rFont) const;
     // finds the font id for the nFaceIndex face in this font file
     // There may be multiple font ids for font collections
diff --git a/vcl/source/fontsubset/fontsubset.cxx 
b/vcl/source/fontsubset/fontsubset.cxx
index 2a45a1194e1a..d0e05058f967 100644
--- a/vcl/source/fontsubset/fontsubset.cxx
+++ b/vcl/source/fontsubset/fontsubset.cxx
@@ -58,20 +58,18 @@ void FontSubsetInfo::LoadFont(
 
 bool FontSubsetInfo::CreateFontSubset(
     FontType nReqFontTypeMask,
-    SvStream* pOutFile, const char* pReqFontName,
+    SvStream* pOutFile,
     const sal_GlyphId* pReqGlyphIds, const sal_uInt8* pReqEncodedIds, int 
nReqGlyphCount)
 {
     // prepare request details needed by all underlying subsetters
     mnReqFontTypeMask = nReqFontTypeMask;
     mpOutFile       = pOutFile;
-    mpReqFontName   = pReqFontName;
     mpReqGlyphIds   = pReqGlyphIds;
     mpReqEncodedIds = pReqEncodedIds;
     mnReqGlyphCount = nReqGlyphCount;
 
     OString aPSName = m_aPSName.toUtf8();
-    if (!mpReqFontName)
-        mpReqFontName = aPSName.getStr();
+    mpReqFontName = aPSName.getStr();
 
     // TODO: move the glyphid/encid/notdef reshuffling from the callers to here
 
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 1c8c2f6b5ff6..8c1040bf279e 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1463,7 +1463,7 @@ bool CreateCFFfontSubset(const unsigned char* pFontBytes, 
int nByteLength,
     SvStream* pStream = aTempFile.GetStream(StreamMode::READWRITE);
 
     rInfo.LoadFont(FontType::CFF_FONT, pFontBytes, nByteLength);
-    bool bRet = rInfo.CreateFontSubset(FontType::TYPE1_PFB, pStream, nullptr, 
pGlyphIds, pEncoding,
+    bool bRet = rInfo.CreateFontSubset(FontType::TYPE1_PFB, pStream, 
pGlyphIds, pEncoding,
                                        nGlyphCount);
 
     if (bRet)
diff --git a/vcl/source/helper/strhelper.cxx b/vcl/source/helper/strhelper.cxx
index ebe48d1200ef..5364274798f6 100644
--- a/vcl/source/helper/strhelper.cxx
+++ b/vcl/source/helper/strhelper.cxx
@@ -251,7 +251,7 @@ int GetCommandLineTokenCount(const OUString& rLine)
     return nTokenCount;
 }
 
-OUString WhitespaceToSpace( std::u16string_view rLine, bool bProtect )
+OUString WhitespaceToSpace( std::u16string_view rLine )
 {
     size_t nLen = rLine.size();
     if( ! nLen )
@@ -283,11 +283,11 @@ OUString WhitespaceToSpace( std::u16string_view rLine, 
bool bProtect )
                 if( pRun != pEnd )
                     pRun++;
             }
-            else if( bProtect && *pRun == '`' )
+            else if( *pRun == '`' )
                 CopyUntil( pLeap, pRun, '`', true );
-            else if( bProtect && *pRun == '\'' )
+            else if( *pRun == '\'' )
                 CopyUntil( pLeap, pRun, '\'', true );
-            else if( bProtect && *pRun == '"' )
+            else if( *pRun == '"' )
                 CopyUntil( pLeap, pRun, '"', true );
             else
             {
diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx 
b/vcl/unx/generic/fontmanager/fontmanager.cxx
index cc4c011d712f..7661d3ace605 100644
--- a/vcl/unx/generic/fontmanager/fontmanager.cxx
+++ b/vcl/unx/generic/fontmanager/fontmanager.cxx
@@ -161,7 +161,7 @@ std::vector<fontID> PrintFontManager::addFontFile( 
std::u16string_view rFileUrl
     return aFontIds;
 }
 
-std::vector<PrintFontManager::PrintFont> PrintFontManager::analyzeFontFile( 
int nDirID, const OString& rFontFile, const char *pFormat ) const
+std::vector<PrintFontManager::PrintFont> PrintFontManager::analyzeFontFile( 
int nDirID, const OString& rFontFile) const
 {
     std::vector<PrintFontManager::PrintFont> aNewFonts;
 
@@ -184,21 +184,12 @@ std::vector<PrintFontManager::PrintFont> 
PrintFontManager::analyzeFontFile( int
             return aNewFonts;
 
         bSupported = false;
-        if (pFormat)
-        {
-            if (!strcmp(pFormat, "TrueType") ||
-                !strcmp(pFormat, "CFF"))
-                bSupported = true;
-        }
-        if (!bSupported)
-        {
-            OString aExt( rFontFile.copy( rFontFile.lastIndexOf( '.' )+1 ) );
-            if( aExt.equalsIgnoreAsciiCase("ttf")
-                 ||  aExt.equalsIgnoreAsciiCase("ttc")
-                 ||  aExt.equalsIgnoreAsciiCase("tte")   // #i33947# for Gaiji 
support
-                 ||  aExt.equalsIgnoreAsciiCase("otf") ) // check for TTF- and 
PS-OpenType too
-                bSupported = true;
-        }
+        OString aExt( rFontFile.copy( rFontFile.lastIndexOf( '.' )+1 ) );
+        if( aExt.equalsIgnoreAsciiCase("ttf")
+             ||  aExt.equalsIgnoreAsciiCase("ttc")
+             ||  aExt.equalsIgnoreAsciiCase("tte")   // #i33947# for Gaiji 
support
+             ||  aExt.equalsIgnoreAsciiCase("otf") ) // check for TTF- and 
PS-OpenType too
+            bSupported = true;
     }
 
     if (bSupported)
diff --git a/vcl/unx/generic/printer/ppdparser.cxx 
b/vcl/unx/generic/printer/ppdparser.cxx
index 2474da389530..b982c1a0a4be 100644
--- a/vcl/unx/generic/printer/ppdparser.cxx
+++ b/vcl/unx/generic/printer/ppdparser.cxx
@@ -1408,7 +1408,7 @@ bool PPDParser::getPaperDimension(
     return true;
 }
 
-OUString PPDParser::matchPaperImpl(int nWidth, int nHeight, bool bSwaped, 
psp::orientation* pOrientation) const
+OUString PPDParser::matchPaperImpl(int nWidth, int nHeight, psp::orientation* 
pOrientation) const
 {
     if( ! m_pPaperDimensions )
         return OUString();
@@ -1439,16 +1439,10 @@ OUString PPDParser::matchPaperImpl(int nWidth, int 
nHeight, bool bSwaped, psp::o
         }
     }
 
-    if (nPDim == -1 && !bSwaped)
-    {
-        // swap portrait/landscape and try again
-        return matchPaperImpl(nHeight, nWidth, true, pOrientation);
-    }
-
     if (nPDim == -1)
         return OUString();
 
-    if (bSwaped && pOrientation)
+    if (pOrientation)
     {
         switch (*pOrientation)
         {
@@ -1466,7 +1460,7 @@ OUString PPDParser::matchPaperImpl(int nWidth, int 
nHeight, bool bSwaped, psp::o
 
 OUString PPDParser::matchPaper(int nWidth, int nHeight, psp::orientation* 
pOrientation) const
 {
-    return matchPaperImpl(nHeight, nWidth, true, pOrientation);
+    return matchPaperImpl(nHeight, nWidth, pOrientation);
 }
 
 OUString PPDParser::getDefaultInputSlot() const
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index c673fdc740e9..f35dad49d141 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -4889,11 +4889,9 @@ namespace
         return Image(aMirrBitmapEx);
     }
 
-    GdkPixbuf* getPixbuf(const css::uno::Reference<css::graphic::XGraphic>& 
rImage, bool bMirror = false)
+    GdkPixbuf* getPixbuf(const css::uno::Reference<css::graphic::XGraphic>& 
rImage)
     {
         Image aImage(rImage);
-        if (bMirror)
-            aImage = mirrorImage(aImage);
 
         OUString sStock(aImage.GetStock());
         if (!sStock.isEmpty())

Reply via email to