tools/source/stream/GenericTypeSerializer.cxx |   12 ++++++++++++
 vcl/source/filter/svm/SvmReader.cxx           |   19 -------------------
 2 files changed, 12 insertions(+), 19 deletions(-)

New commits:
commit 3d7b0a6ebbf5154933bc4a450613362052167791
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Feb 27 14:06:47 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Feb 28 07:23:23 2023 +0000

    move sanitizing of Size inside GenericTypeSerializer
    
    I cannot see a useful application of a Size that is negative
    (at least not in a file format).
    
    Change-Id: I0c5bd8c7d3987a5c7803af2a6ae0543c4a6d7754
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147884
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/tools/source/stream/GenericTypeSerializer.cxx 
b/tools/source/stream/GenericTypeSerializer.cxx
index 8abe23237d85..3eefb008ea67 100644
--- a/tools/source/stream/GenericTypeSerializer.cxx
+++ b/tools/source/stream/GenericTypeSerializer.cxx
@@ -130,6 +130,18 @@ void GenericTypeSerializer::readSize(Size& rSize)
 
     rSize.setWidth(nWidth);
     rSize.setHeight(nHeight);
+
+    // sanitize negative size dimensions
+    if (rSize.Width() < 0)
+    {
+        SAL_WARN("tools", "negative width");
+        rSize.setWidth(0);
+    }
+    if (rSize.Height() < 0)
+    {
+        SAL_WARN("tools", "negative height");
+        rSize.setHeight(0);
+    }
 }
 
 void GenericTypeSerializer::writeSize(const Size& rSize)
diff --git a/vcl/source/filter/svm/SvmReader.cxx 
b/vcl/source/filter/svm/SvmReader.cxx
index a7a4dcbd7817..6d84d44d879f 100644
--- a/vcl/source/filter/svm/SvmReader.cxx
+++ b/vcl/source/filter/svm/SvmReader.cxx
@@ -55,21 +55,6 @@ public:
         m_rData.meActualCharSet = m_eOrigCharSet;
     }
 };
-
-void sanitizeNegativeSizeDimensions(Size& rSize)
-{
-    if (rSize.Width() < 0)
-    {
-        SAL_WARN("vcl.gdi", "sanitizeNegativeSizeDimensions: negative width");
-        rSize.setWidth(0);
-    }
-
-    if (rSize.Height() < 0)
-    {
-        SAL_WARN("vcl.gdi", "sanitizeNegativeSizeDimensions: negative height");
-        rSize.setHeight(0);
-    }
-}
 }
 
 SvmReader::SvmReader(SvStream& rIStm)
@@ -110,7 +95,6 @@ SvStream& SvmReader::Read(GDIMetaFile& rMetaFile, 
ImplMetaReadData* pData)
             rMetaFile.SetPrefMapMode(aMapMode);
             Size aSize;
             aSerializer.readSize(aSize);
-            sanitizeNegativeSizeDimensions(aSize);
             rMetaFile.SetPrefSize(aSize);
             mrStream.ReadUInt32(nCount);
 
@@ -884,7 +868,6 @@ rtl::Reference<MetaAction> SvmReader::BmpScaleHandler()
 
     Size aSz;
     aSerializer.readSize(aSz);
-    sanitizeNegativeSizeDimensions(aSz);
 
     pAction->SetBitmap(aBmp);
     pAction->SetPoint(aPoint);
@@ -949,7 +932,6 @@ rtl::Reference<MetaAction> SvmReader::BmpExScaleHandler()
 
     Size aSize;
     aSerializer.readSize(aSize);
-    sanitizeNegativeSizeDimensions(aSize);
 
     pAction->SetBitmapEx(aBmpEx);
     pAction->SetPoint(aPoint);
@@ -1340,7 +1322,6 @@ rtl::Reference<MetaAction> 
SvmReader::FloatTransparentHandler(ImplMetaReadData*
 
     Size aSize;
     aSerializer.readSize(aSize);
-    sanitizeNegativeSizeDimensions(aSize);
 
     Gradient aGradient;
     aSerializer.readGradient(aGradient);

Reply via email to