Skip to content

Commit

Permalink
Merge pull request #2474 from nrspruit/fix_use_after_free_build_strings
Browse files Browse the repository at this point in the history
[L0] Fix use after free with Module build strings
  • Loading branch information
martygrant authored Dec 18, 2024
2 parents 7c1d23b + 3973136 commit 9c816fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions source/adapters/level_zero/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,9 @@ ur_result_t urProgramLinkExp(
// Build flags may be different for different devices, so handle them
// here. Clear values of the previous device first.
BuildFlagPtrs.clear();
std::vector<std::string> TemporaryOptionsStrings;
for (uint32_t I = 0; I < count; I++) {
TemporaryOptionsStrings.push_back(
phPrograms[I]->getBuildOptions(ZeDevice));
BuildFlagPtrs.push_back(TemporaryOptionsStrings.back().c_str());
BuildFlagPtrs.push_back(
phPrograms[I]->getBuildOptions(ZeDevice).c_str());
}
ZeExtModuleDesc.pBuildFlags = BuildFlagPtrs.data();
if (count == 1)
Expand Down
2 changes: 1 addition & 1 deletion source/adapters/level_zero/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ struct ur_program_handle_t_ : _ur_object {
DeviceDataMap[ZeDevice].BuildFlags += Options;
}

std::string getBuildOptions(ze_device_handle_t ZeDevice) {
std::string &getBuildOptions(ze_device_handle_t ZeDevice) {
return DeviceDataMap[ZeDevice].BuildFlags;
}

Expand Down

0 comments on commit 9c816fe

Please sign in to comment.