Commit ab0b7510 authored by Simon Giesecke's avatar Simon Giesecke
Browse files

Bug 1665026 - Prevent ToResultInvoke from being instantiated with a raw pointer result type. r=janv

parent 084f4ffe
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -66,6 +66,14 @@ template <typename R, typename RArgMapper, typename Func, typename... Args>
Result<R, nsresult> ToResultInvokeInternal(const Func& aFunc,
                                           const RArgMapper& aRArgMapper,
                                           Args&&... aArgs) {
  // XXX Thereotically, if R is a pointer to a non-refcounted type, this might
  // be a non-owning pointer, but unless we find a case where this actually is
  // relevant, it's safe to forbid any raw pointer result.
  static_assert(
      !std::is_pointer_v<R>,
      "Raw pointer results are not supported, please specify a smart pointer "
      "result type explicitly, so that getter_AddRefs is used");

  R res;
  nsresult rv = aFunc(std::forward<Args>(aArgs)..., aRArgMapper(res));
  if (NS_FAILED(rv)) {