Skip to content

Commit efee051

Browse files
authored
[UR] Fix logger use after move (Coverity) (#18665)
When the callback sink and the standard sink are both enabled using `std::forward<Args>(args)...` results in a use-after-move. This patches fixes the issue by letting the r-value references decay to l-value references when expanding the `args...` parameter pack and allowing the parameter pack to be passed to multiple functions. The `logger::log()` member function does not need to take ownership of the objects being passed in.
1 parent 6f324d3 commit efee051

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

unified-runtime/source/common/logger/ur_logger_details.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,19 @@ class Logger {
5555
const char *filename, const char *lineno, const char *format,
5656
Args &&...args) {
5757
if (callbackSink && level >= this->callbackSinkLevel) {
58-
callbackSink->log(level, filename, lineno, format,
59-
std::forward<Args>(args)...);
58+
callbackSink->log(level, filename, lineno, format, args...);
6059
}
6160

6261
if (standardSink) {
6362
if (isLegacySink) {
64-
standardSink->log(level, filename, lineno, p.message,
65-
std::forward<Args>(args)...);
63+
standardSink->log(level, filename, lineno, p.message, args...);
6664
return;
6765
}
6866

6967
if (level < this->standardSinkLevel) {
7068
return;
7169
}
72-
standardSink->log(level, filename, lineno, format,
73-
std::forward<Args>(args)...);
70+
standardSink->log(level, filename, lineno, format, args...);
7471
}
7572
}
7673

0 commit comments

Comments
 (0)