summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-02-27 14:06:47 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-02-28 07:23:23 +0000
commit3d7b0a6ebbf5154933bc4a450613362052167791 (patch)
tree430cb65055d0d61d193e091835578f8b4efa86ae /tools
parenteae92409e7aefb0837a0408563bd3787406aab8c (diff)
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.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/stream/GenericTypeSerializer.cxx12
1 files changed, 12 insertions, 0 deletions
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)