summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-07-26 21:45:51 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-07-27 07:33:39 +0200
commit0ea2f9a1b33b446069935913c2b3c846d79b52de (patch)
treeade4da40599b7797f2fffad94b69700971a43c3a /toolkit
parent67f2a99229101757af4f40118f4d3c83ba38648b (diff)
Avoid potential tools::Long vs. UNOIDL LONG mismatch
As found when debugging tdf#143534 "Crash in Calc NLP Solver when saving a document in Write" on Linux x86-64 (where tools::Long is 64-bit long; while UNOIDL LONG is 32-bit): These ImplSetPropertyValues cause comphelper::OPropertyContainerHelper::convertFastPropertyValue to throw via lcl_throwIllegalPropertyValueTypeException due to the mismatch---which were then silently caught in UnoDialogControl::windowResized resp. UnoDialogControl::windowMoved. Change-Id: I9793204ad49737165e69de7d5e15445ba0e82c85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119535 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/source/controls/dialogcontrol.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx
index 25e8061e5e1b..c53b6c808751 100644
--- a/toolkit/source/controls/dialogcontrol.cxx
+++ b/toolkit/source/controls/dialogcontrol.cxx
@@ -17,7 +17,11 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+#include <algorithm>
+
+#include <sal/types.h>
#include <vcl/svapp.hxx>
#include <osl/mutex.hxx>
#include <controls/dialogcontrol.hxx>
@@ -507,8 +511,10 @@ void SAL_CALL UnoDialogControl::windowResized( const css::awt::WindowEvent& e )
// Properties in a sequence must be sorted!
aProps[0] = "Height";
aProps[1] = "Width";
- aValues[0] <<= aAppFontSize.Height();
- aValues[1] <<= aAppFontSize.Width();
+ aValues[0] <<= sal_Int32(
+ std::clamp(aAppFontSize.Height(), tools::Long(SAL_MIN_INT32), tools::Long(SAL_MAX_INT32)));
+ aValues[1] <<= sal_Int32(
+ std::clamp(aAppFontSize.Width(), tools::Long(SAL_MIN_INT32), tools::Long(SAL_MAX_INT32)));
ImplSetPropertyValues( aProps, aValues, true );
mbSizeModified = false;
@@ -533,8 +539,10 @@ void SAL_CALL UnoDialogControl::windowMoved( const css::awt::WindowEvent& e )
Sequence< Any > aValues( 2 );
aProps[0] = "PositionX";
aProps[1] = "PositionY";
- aValues[0] <<= aTmp.Width();
- aValues[1] <<= aTmp.Height();
+ aValues[0] <<= sal_Int32(
+ std::clamp(aTmp.Width(), tools::Long(SAL_MIN_INT32), tools::Long(SAL_MAX_INT32)));
+ aValues[1] <<= sal_Int32(
+ std::clamp(aTmp.Height(), tools::Long(SAL_MIN_INT32), tools::Long(SAL_MAX_INT32)));
ImplSetPropertyValues( aProps, aValues, true );
mbPosModified = false;