summaryrefslogtreecommitdiff
path: root/binaryurp
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-06-04 16:10:48 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-06-04 23:19:39 +0200
commit56428bd9ad98221ad3631dd1e0d6c80881a88056 (patch)
tree3f33929b7c099ce0bb26b4dd12762405bfe51b9d /binaryurp
parent112d8113388513d9c6b317e828f5d373b4a54330 (diff)
Properly handle initial object queryInterface return value
<https://wiki.openoffice.org/wiki/Uno/Remote/Specifications/Uno_Remote_Protocol# The_queryInterface_Message> specifies that this shall return an ANY either of type VOID (so handle that) or of type css.uno.XInterface with non-null value (so throw exceptions for any other kinds of return values). Various Linux Jenkins builds had recently started to sporadically fail during UITest_calc_demo, hitting the assert( type.get()->eTypeClass == typelib_TypeClass_ANY || type.equals(css::uno::TypeDescription(data_.pType))); in the call to binaryurp::BinaryAny::getValue (binaryurp/source/binaryany.cxx), e.g. <<https://ci.libreoffice.org/job/lo_tb_master_linux_dbg/29831/>. While it is unclear why those failures happen, they highlight that this code did not properly handle all possible (valid or invalid) input. Change-Id: I95db574aa102ff75fa22fd24c697a0cfa24b7aff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95527 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'binaryurp')
-rw-r--r--binaryurp/source/bridge.cxx18
1 files changed, 17 insertions, 1 deletions
diff --git a/binaryurp/source/bridge.cxx b/binaryurp/source/bridge.cxx
index 1be59b933a70..4d375f414719 100644
--- a/binaryurp/source/bridge.cxx
+++ b/binaryurp/source/bridge.cxx
@@ -50,6 +50,7 @@
#include <rtl/ustring.hxx>
#include <sal/log.hxx>
#include <sal/types.h>
+#include <typelib/typeclass.h>
#include <typelib/typedescription.h>
#include <typelib/typedescription.hxx>
#include <uno/dispatcher.hxx>
@@ -873,10 +874,25 @@ css::uno::Reference< css::uno::XInterface > Bridge::getInstance(
"com.sun.star.uno.XInterface::queryInterface"),
false, inArgs, &ret, &outArgs);
throwException(bExc, ret);
+ auto const t = ret.getType();
+ if (t.get()->eTypeClass == typelib_TypeClass_VOID) {
+ return {};
+ }
+ if (!t.equals(ifc)) {
+ throw css::uno::RuntimeException(
+ "initial object queryInterface for OID \"" + sInstanceName + "\" returned ANY of type "
+ + OUString::unacquired(&t.get()->pTypeName));
+ }
+ auto const val = *static_cast< uno_Interface ** >(ret.getValue(ifc));
+ if (val == nullptr) {
+ throw css::uno::RuntimeException(
+ "initial object queryInterface for OID \"" + sInstanceName
+ + "\" returned null css.uno.XInterface ANY");
+ }
return css::uno::Reference< css::uno::XInterface >(
static_cast< css::uno::XInterface * >(
binaryToCppMapping_.mapInterface(
- *static_cast< uno_Interface ** >(ret.getValue(ifc)),
+ val,
ifc.get())),
SAL_NO_ACQUIRE);
}