Skip to content

Commit f09091a

Browse files
authored
Merge pull request #2474 from nrspruit/fix_use_after_free_build_strings
[L0] Fix use after free with Module build strings
2 parents 71342ad + 3b81059 commit f09091a

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

source/adapters/level_zero/program.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,9 @@ ur_result_t urProgramLinkExp(
452452
// Build flags may be different for different devices, so handle them
453453
// here. Clear values of the previous device first.
454454
BuildFlagPtrs.clear();
455-
std::vector<std::string> TemporaryOptionsStrings;
456455
for (uint32_t I = 0; I < count; I++) {
457-
TemporaryOptionsStrings.push_back(
458-
phPrograms[I]->getBuildOptions(ZeDevice));
459-
BuildFlagPtrs.push_back(TemporaryOptionsStrings.back().c_str());
456+
BuildFlagPtrs.push_back(
457+
phPrograms[I]->getBuildOptions(ZeDevice).c_str());
460458
}
461459
ZeExtModuleDesc.pBuildFlags = BuildFlagPtrs.data();
462460
if (count == 1)

source/adapters/level_zero/program.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ struct ur_program_handle_t_ : _ur_object {
169169
DeviceDataMap[ZeDevice].BuildFlags += Options;
170170
}
171171

172-
std::string getBuildOptions(ze_device_handle_t ZeDevice) {
172+
std::string &getBuildOptions(ze_device_handle_t ZeDevice) {
173173
return DeviceDataMap[ZeDevice].BuildFlags;
174174
}
175175

0 commit comments

Comments
 (0)