Skip to content

Commit

Permalink
Fix a bug with WASM_SIMD, and hardens write_headers when comments are…
Browse files Browse the repository at this point in the history
… NULL.
  • Loading branch information
aous72 committed Aug 24, 2023
1 parent c11baf5 commit 1d19e4f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/core/codestream/ojph_codeblock_fun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ namespace ojph {
tx_to_cb = wasm_irv_tx_to_cb;
tx_from_cb = wasm_irv_tx_from_cb;
}
encode_cb = ojph_encode_codeblock;

#endif // !OJPH_ENABLE_WASM_SIMD

Expand Down
30 changes: 16 additions & 14 deletions src/core/codestream/ojph_codestream_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,20 +652,22 @@ namespace ojph {
if (file->write(buf, len) != len)
OJPH_ERROR(0x00030027, "Error writing to file");

for (ui32 i = 0; i < num_comments; ++i)
{
t = swap_byte(JP2K_MARKER::COM);
if (file->write(&t, 2) != 2)
OJPH_ERROR(0x00030028, "Error writing to file");
t = swap_byte((ui16)(comments[i].len + 4));
if (file->write(&t, 2) != 2)
OJPH_ERROR(0x00030029, "Error writing to file");
//1 for General use (IS 8859-15:1999 (Latin) values)
t = swap_byte(comments[i].Rcom);
if (file->write(&t, 2) != 2)
OJPH_ERROR(0x0003002A, "Error writing to file");
if (file->write(comments[i].data, comments[i].len) != comments[i].len)
OJPH_ERROR(0x0003002B, "Error writing to file");
if (comments != NULL) {
for (ui32 i = 0; i < num_comments; ++i)
{
t = swap_byte(JP2K_MARKER::COM);
if (file->write(&t, 2) != 2)
OJPH_ERROR(0x00030028, "Error writing to file");
t = swap_byte((ui16)(comments[i].len + 4));
if (file->write(&t, 2) != 2)
OJPH_ERROR(0x00030029, "Error writing to file");
//1 for General use (IS 8859-15:1999 (Latin) values)
t = swap_byte(comments[i].Rcom);
if (file->write(&t, 2) != 2)
OJPH_ERROR(0x0003002A, "Error writing to file");
if (file->write(comments[i].data, comments[i].len)!=comments[i].len)
OJPH_ERROR(0x0003002B, "Error writing to file");
}
}
}

Expand Down

0 comments on commit 1d19e4f

Please sign in to comment.