Skip to content
Snippets Groups Projects
Commit 5c72aa7c authored by Lioncash's avatar Lioncash
Browse files

patch_manager: Prevent use of a dangling pointer within PatchRomFS

fmt::format() returns a std::string instance by value, so calling
.c_str() on it here is equivalent to doing:

auto* ptr = std::string{}.c_str();

The data being pointed to isn't guaranteed to actually be valid anymore
after that expression ends. Instead, we can just take the string as is,
and provide the necessary formatting parameters.
parent 3b1043c5
No related branches found
No related tags found
No related merge requests found
...@@ -286,13 +286,12 @@ static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType t ...@@ -286,13 +286,12 @@ static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType t
VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, ContentRecordType type, VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, ContentRecordType type,
VirtualFile update_raw) const { VirtualFile update_raw) const {
const auto log_string = fmt::format("Patching RomFS for title_id={:016X}, type={:02X}", const auto log_string = fmt::format("Patching RomFS for title_id={:016X}, type={:02X}",
title_id, static_cast<u8>(type)) title_id, static_cast<u8>(type));
.c_str();
if (type == ContentRecordType::Program || type == ContentRecordType::Data) if (type == ContentRecordType::Program || type == ContentRecordType::Data)
LOG_INFO(Loader, log_string); LOG_INFO(Loader, "{}", log_string);
else else
LOG_DEBUG(Loader, log_string); LOG_DEBUG(Loader, "{}", log_string);
if (romfs == nullptr) if (romfs == nullptr)
return romfs; return romfs;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment