face: Fix segfault caused by Face::unregisterPrefix when registeredPrefixId does not exist
Change-Id: I67e86679fc80506bca439a2a8264c485309f97f3
diff --git a/src/detail/face-impl.hpp b/src/detail/face-impl.hpp
index 8e48750..cd1b3d8 100644
--- a/src/detail/face-impl.hpp
+++ b/src/detail/face-impl.hpp
@@ -270,8 +270,11 @@
(*i)->unregister(bind(&Impl::finalizeUnregisterPrefix, this, i, onSuccess),
bind(onFailure, _2));
}
- else
- onFailure("Unrecognized PrefixId");
+ else {
+ if (static_cast<bool>(onFailure)) {
+ onFailure("Unrecognized PrefixId");
+ }
+ }
// there cannot be two registered prefixes with the same id
}