[Libreoffice-commits] core.git: include/rtl vcl/source writerfilter/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Thu Dec 10 21:22:06 UTC 2020


 include/rtl/string.hxx                           |    6 ++++++
 vcl/source/filter/ipdf/pdfread.cxx               |    4 ++--
 writerfilter/source/rtftok/rtfdispatchsymbol.cxx |    2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

New commits:
commit 9df9208b7d0fd9dd49c681c3c1b546d8ca402925
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Dec 10 15:15:40 2020 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Dec 10 22:21:23 2020 +0100

    Catch inadvertent uses of OString(char) ctor
    
    ...similar to cbe944e323edb20f958bb46ea644de659b75382e "Catch inadvertent uses
    of OUString(sal_Unicode) ctor".  The existing few places did mean to use that
    ctor after all, but this clean-up should come in handy when single-character
    instances of OString are replaced with OStringChar, which already rejects non-
    char arguments.
    
    Change-Id: I9dbd85b85c3be653c5e8084aed39689f8c6c3bb8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107557
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index 4d229fd86931..3c540198f95f 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -243,6 +243,12 @@ public:
         rtl_string_newFromStr_WithLength( &pData, &value, 1 );
     }
 
+#if defined LIBO_INTERNAL_ONLY && !defined RTL_STRING_UNITTEST_CONCAT
+    // Catch inadvertent conversions to the above ctor (e.g., from sal_[u]Int8, aka [un]signed
+    // char):
+    OString(int) = delete;
+#endif
+
     /**
       New string from a character buffer array.
 
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index a36eacbfd41a..ef5d799fe4ee 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -54,8 +54,8 @@ bool isCompatible(SvStream& rInStream, sal_uInt64 nPos, sal_uInt64 nSize)
         || aFirstBytes[3] != 'F' || aFirstBytes[4] != '-')
         return false;
 
-    sal_Int32 nMajor = OString(aFirstBytes[5]).toInt32();
-    sal_Int32 nMinor = OString(aFirstBytes[7]).toInt32();
+    sal_Int32 nMajor = OString(char(aFirstBytes[5])).toInt32();
+    sal_Int32 nMinor = OString(char(aFirstBytes[7])).toInt32();
     return !(nMajor > 1 || (nMajor == 1 && nMinor > 6));
 }
 
diff --git a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
index ff13dedcf5fa..418498f98df3 100644
--- a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
@@ -80,7 +80,7 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
     }
     if (cCh > 0)
     {
-        OUString aStr(OStringToOUString(OString(cCh), RTL_TEXTENCODING_MS_1252));
+        OUString aStr(OStringToOUString(OString(char(cCh)), RTL_TEXTENCODING_MS_1252));
         text(aStr);
         return RTFError::OK;
     }


More information about the Libreoffice-commits mailing list