mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Fix Potential Use-After-Free of Temporary Twine
Twine is non-owning and the lifetime of the result ends at the semicolon here unless it is consumed into an owning abstraction. Convert to a std::string first then insert that into the buffer here. Not a big deal since this is along a catastrophic error path.
This commit is contained in:
@@ -1938,8 +1938,8 @@ OverlayFileContents::load(std::unique_ptr<llvm::MemoryBuffer> input,
|
||||
return error;
|
||||
|
||||
if (contents.version > 1) {
|
||||
auto message = Twine("key 'version' has invalid value: ") + Twine(contents.version);
|
||||
errorMessages.push_back(message.str());
|
||||
std::string message = (Twine("key 'version' has invalid value: ") + Twine(contents.version)).str();
|
||||
errorMessages.emplace_back(std::move(message));
|
||||
return make_error_code(std::errc::result_out_of_range);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user