Skip to content

Commit

Permalink
Linux/GenerateMap: Fixes FD leak
Browse files Browse the repository at this point in the history
This FD was unused
  • Loading branch information
Sonicadvance1 committed Sep 9, 2024
1 parent 28fd3d7 commit e309f85
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,15 +993,10 @@ SyscallHandler::GenerateMap(const std::string_view& GuestBinaryFile, const std::
// objdump output parsing, index generation, index file serialization
DoGenerate:
LogMan::Msg::DFmt("GenerateMap: Generating index for '{}'", GuestSourceFile);
int StreamFD = ::open(GuestSourceFile.c_str(), O_RDONLY | O_CLOEXEC);

if (StreamFD == -1) {
LogMan::Msg::DFmt("GenerateMap: Failed to open '{}'", GuestSourceFile);
return {};
}

fextl::string SourceData;
if (!FEXCore::FileLoading::LoadFile(SourceData, GuestSourceFile)) {
LogMan::Msg::DFmt("GenerateMap: Failed to open '{}'", GuestSourceFile);
return {};
}
fextl::istringstream Stream(SourceData);
Expand Down Expand Up @@ -1194,10 +1189,6 @@ SyscallHandler::GenerateMap(const std::string_view& GuestBinaryFile, const std::
}
}

if (StreamFD != -1) {
close(StreamFD);
}

if (IndexStream != -1) {
close(IndexStream);
}
Expand Down

0 comments on commit e309f85

Please sign in to comment.