Skip to content

Commit 517761d

Browse files
[SYCL] Fix use-after-free for MockHandler::getKernelName() (#18801)
In current implementation, std::string is returned from getKernelName(). For preview, caller of getKernelName() creates std::string_view from the returned temporary string. This sting_view is used after the temporary string is destroyed. In the fix for preview std::string_view is returned, that points to same kernel name as handler::MKernel.
1 parent 911dedf commit 517761d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sycl/unittests/scheduler/SchedulerTestUtils.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,9 @@ class MockHandler : public sycl::handler {
253253
return impl->CGData.MEvents;
254254
}
255255
std::vector<sycl::detail::ArgDesc> &getArgs() { return impl->MArgs; }
256-
std::string getKernelName() { return MKernelName.data(); }
256+
sycl::detail::KernelNameStrT getKernelName() {
257+
return toKernelNameStrT(MKernelName);
258+
}
257259
std::shared_ptr<sycl::detail::kernel_impl> &getKernel() { return MKernel; }
258260
std::shared_ptr<sycl::detail::HostTask> &getHostTask() {
259261
return impl->MHostTask;

0 commit comments

Comments
 (0)