Commit be3370be authored by bastien penavayre's avatar bastien penavayre Committed by Hugo Beauzée-Luyssen

Fix crash for implicit cast of NULL from char * to std::string

-Adds a template function that return its argument untouched for all type except for const char *
-For const char * it returns the argument if it's not null otherwise returns an empty string
-Call this function in the wrap method when unpacking the parameter pack
Signed-off-by: default avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent e6ab30cb
......@@ -149,6 +149,21 @@ namespace VLC
}
};
namespace detail
{
template <typename ArgType>
ArgType &&converterForNullToString(ArgType &&arg)
{
return std::forward<ArgType>(arg);
}
template <>
inline const char * &&converterForNullToString(const char * &&str)
{
return std::forward<const char *>(str == nullptr ? "" : str);
}
}
template <size_t Idx, typename... Args>
struct CallbackWrapper;
......@@ -171,7 +186,7 @@ namespace VLC
auto& callbacks = FromOpaque<NbEvents, Opaque>::get( opaque );
assert(callbacks[Idx] != nullptr);
auto cbHandler = static_cast<CallbackHandler<Func>*>( callbacks[Idx].get() );
return cbHandler->func( std::forward<Args>(args)... );
return cbHandler->func( detail::converterForNullToString<Args>(std::forward<Args>(args))... );
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment