Page MenuHomePhabricator

context->GetServiceReference<>() crashes
Closed, ResolvedPublic

Description

In a unittest I stumbled across a crash in
context->GetServiceReference<someInterface>() because the implementation of 'someInterface' had not been registered in the unittest.

I had expected some exception to be thrown in this case, as was written in the documentation of "ServiceReference<S> mitk::ModuleContext::GetServiceReference()".

However, the code simply crashes in
ServiceReferenceBasePrivate::IsConvertibleTo( string ) as the internal 'registration' instance is NULL.

There should either be an invalid ServiceReference or an exception (better)...

Event Timeline

You are right, the ServiceReferenceBasePrivate::IsConvertibleTo() method should check its 'registration' member before accessing it.

New remote branch pushed: bug-16193-fix-getservicereference-crash

[03a938]: Merge branch 'bug-16193-fix-getservicereference-crash'

Merged commits:

2013-09-29 22:28:56 Sascha Zelzer [4d08bc]
Merge commit '9b145a803d5350563d251be59e7b9a8e648d601c' into bug-16193-fix-getservicereference-crash


2013-09-29 22:28:56 Sascha Zelzer [9b145a]
Squashed 'Core/CppMicroServices/' changes from 2a5abcb..e8a4f21

e8a4f21 Fixed ServiceReference conversion test in case of an invalid reference.

git-subtree-dir: Core/CppMicroServices
git-subtree-split: e8a4f21aa7286ceb5c65db05c121859872ee8401