Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion import/chips/p9/utils/imageProcs/p9_scan_compression.C
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,6 @@ int
rs4_embed_cmsk( CompressedScanData** io_rs4,
CompressedScanData* i_rs4Cmsk )
{
char* embeddedAddr = (char*)(*io_rs4 + 1);
size_t embeddedSize = be16toh(i_rs4Cmsk->iv_size);
size_t totalSize = be16toh((*io_rs4)->iv_size) + embeddedSize;

Expand All @@ -931,6 +930,10 @@ rs4_embed_cmsk( CompressedScanData** io_rs4,
return BUG(SCAN_COMPRESSION_NO_MEMORY);
}

// realloc() above may move the buffer, so derive the embedded address from
// the (possibly new) *io_rs4 pointer rather than from the pre-realloc one.
char* embeddedAddr = (char*)(*io_rs4 + 1);

// Make space for cmsk ring
memmove(embeddedAddr + embeddedSize,
embeddedAddr,
Expand Down