summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-05-03 15:19:21 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-05-03 15:25:44 +0200
commitab3d2e568fe1595584c66c2ff07843e72f608944 (patch)
treef8490f9286c1cb3012c74743a864d6d9bb4ce7e4
parent2ce95e838260ed1e7e64ac8f5662aa2e2234ab9e (diff)
Prevent Any ctor from reinterpreting bool* as sal_Bool*
...which only happens to work in environments where sizeof (bool) == 1. The simpler alternative is to use the Any ctor template without passing explicit UNO type information, anyway. The std::nullptr_t overloads are needed to disambiguate calls with a nullptr argument. (Which can at least be meaningful for VOID, but for other types what it happens to do is store a default value of the given type.) As std::nullptr_t is only C++11, this all needs to be LIBO_INTERNAL_ONLY. Change-Id: I0f72c73a088ef96e069c3ed8c78546b16d89b50a
-rw-r--r--cui/source/options/connpoolconfig.cxx2
-rw-r--r--include/com/sun/star/uno/Any.h16
-rw-r--r--sc/source/core/data/dpsave.cxx2
3 files changed, 18 insertions, 2 deletions
diff --git a/cui/source/options/connpoolconfig.cxx b/cui/source/options/connpoolconfig.cxx
index 31423f5431a8..00b46cde8e1d 100644
--- a/cui/source/options/connpoolconfig.cxx
+++ b/cui/source/options/connpoolconfig.cxx
@@ -186,7 +186,7 @@ namespace offapp
// set the values
aThisDriverSettings.setNodeValue(getDriverNameNodeName(), makeAny(sThisDriverName));
- aThisDriverSettings.setNodeValue(getEnableNodeName(), Any(&aLoop->bEnabled, cppu::UnoType<bool>::get()));
+ aThisDriverSettings.setNodeValue(getEnableNodeName(), Any(aLoop->bEnabled));
aThisDriverSettings.setNodeValue(getTimeoutNodeName(), makeAny(aLoop->nTimeoutSeconds));
}
bNeedCommit = true;
diff --git a/include/com/sun/star/uno/Any.h b/include/com/sun/star/uno/Any.h
index ad26da1cbf64..c46a59e2f0cc 100644
--- a/include/com/sun/star/uno/Any.h
+++ b/include/com/sun/star/uno/Any.h
@@ -19,6 +19,10 @@
#ifndef INCLUDED_COM_SUN_STAR_UNO_ANY_H
#define INCLUDED_COM_SUN_STAR_UNO_ANY_H
+#include <sal/config.h>
+
+#include <cstddef>
+
#include <uno/any2.h>
#include <typelib/typedescription.h>
#include <cppu/unotype.hxx>
@@ -101,6 +105,18 @@ public:
*/
inline Any( const void * pData_, typelib_TypeDescriptionReference * pType_ );
+#if defined LIBO_INTERNAL_ONLY
+ Any(bool const *, Type const &) = delete;
+ Any(bool const *, typelib_TypeDescription *) = delete;
+ Any(bool const *, typelib_TypeDescriptionReference *) = delete;
+ Any(std::nullptr_t, Type const & type):
+ Any(static_cast<void *>(nullptr), type) {}
+ Any(std::nullptr_t, typelib_TypeDescription * type):
+ Any(static_cast<void *>(nullptr), type) {}
+ Any(std::nullptr_t, typelib_TypeDescriptionReference * type):
+ Any(static_cast<void *>(nullptr), type) {}
+#endif
+
/** Destructor: Destructs any content and frees memory.
*/
inline ~Any();
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 20c3488f524e..15920edf3554 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -64,7 +64,7 @@ static void lcl_SetBoolProperty( const uno::Reference<beans::XPropertySet>& xPro
{
//TODO: move to ScUnoHelpFunctions?
- xProp->setPropertyValue( rName, uno::Any( &bValue, cppu::UnoType<bool>::get() ) );
+ xProp->setPropertyValue( rName, uno::Any( bValue ) );
}
ScDPSaveMember::ScDPSaveMember(const OUString& rName) :