Skip to content

Commit

Permalink
Add alignment check per CR.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoikas committed Mar 5, 2024
1 parent a10a3f7 commit 31d53e2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/Util/plJPEG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ void plJPEG::DecompressJPEG(hsStream* S, void* buf, size_t size)
}

// Data stored as RGB on disk but Plasma uses BGR
if (reinterpret_cast<uintptr_t>(buf) % sizeof(uint32_t) != 0)
throw hsBadParamException(__FILE__, __LINE__, "buf should be aligned on a 32-bit boundary");

uint32_t* dp = reinterpret_cast<uint32_t*>(buf);
for (size_t i=0; i<size; i += 4) {
*dp = (*dp & 0xFF00FF00)
Expand Down

0 comments on commit 31d53e2

Please sign in to comment.