Skip to content

Commit

Permalink
Fix UB if uncompressedIn is zero-sized
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilDohne committed Oct 16, 2024
1 parent 326ee82 commit 5210de9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 0 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"environment": {
"CFLAGS": "/fsanitize=address /Zi",
"CXXFLAGS": "/fsanitize=address /Zi"
}
},
{
Expand Down
4 changes: 4 additions & 0 deletions PhotoshopAPI/src/Core/Compression/Compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ inline std::vector<uint8_t> CompressData(std::span<T> uncompressedIn, std::span<
{
if (compression == Enum::Compression::Raw)
{
if (uncompressedIn.size() == 0)
{
return {};
}
endianEncodeBEArray(uncompressedIn);
std::vector<uint8_t> data(uncompressedIn.size() * sizeof(T));
std::memcpy(reinterpret_cast<void*>(data.data()), reinterpret_cast<void*>(uncompressedIn.data()), data.size());
Expand Down

0 comments on commit 5210de9

Please sign in to comment.