binaryurp/source/bridge.cxx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
New commits: commit 56428bd9ad98221ad3631dd1e0d6c80881a88056 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Thu Jun 4 16:10:48 2020 +0200 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Thu Jun 4 23:19:39 2020 +0200 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 <sberg...@redhat.com> 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); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits