adamdebreceni commented on code in PR #1460:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1460#discussion_r1063442029
##########
libminifi/include/core/logging/Logger.h:
##########
@@ -72,6 +76,8 @@ inline decltype(auto) conditional_convert(const Arg& val) {
return val;
} else if constexpr (std::is_same_v<decltype(std::declval<const
Arg&>().c_str()), const char*>) {
return val.c_str();
+ } else if constexpr (std::is_same_v<decltype(std::declval<const
Arg&>().string()), std::string>) {
+ return val.string().c_str();
Review Comment:
the `::string() const` method could return a temporary which is destroyed
before using the result of `c_str()` leaving us with UB, I think for this to be
safe, the `conditional_stringify` functions should call the `::string() const`
method, the returned temporary string is kept alive until the end of the full
expression the `conditional_stringify` is part of, which is after
`format_string` returns
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]