Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression in reading files with TNsot == 0 (refs #1120) #1121

Merged
merged 3 commits into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions src/lib/openjp2/j2k.c
Original file line number Diff line number Diff line change
Expand Up @@ -4094,7 +4094,12 @@ static OPJ_BOOL opj_j2k_merge_ppt(opj_tcp_t *p_tcp, opj_event_mgr_t * p_manager)
/* preconditions */
assert(p_tcp != 00);
assert(p_manager != 00);
assert(p_tcp->ppt_buffer == NULL);

if (p_tcp->ppt_buffer != NULL) {
opj_event_msg(p_manager, EVT_ERROR,
"opj_j2k_merge_ppt() has already been called\n");
return OPJ_FALSE;
}

if (p_tcp->ppt == 0U) {
return OPJ_TRUE;
Expand Down Expand Up @@ -8845,7 +8850,10 @@ OPJ_BOOL opj_j2k_read_tile_header(opj_j2k_t * p_j2k,

/* Current marker is the EOC marker ?*/
if (l_current_marker == J2K_MS_EOC) {
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_EOC;
if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_EOC) {
p_j2k->m_current_tile_number = 0;
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_EOC;
}
}

/* FIXME DOC ???*/
Expand Down
3 changes: 2 additions & 1 deletion tests/nonregression/md5refs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,5 @@ ac8f6ab3acc9c692ed7c41bd62a0e1e8 file1.jp2-c0-r1.tif
fbfcf662b6f7549574b2885490fbcf12 file1.jp2-c0-d10_20_30_40.tif
fa7382fd8b2e788b28b807e200dd95b9 file1.jp2-c0-t0.tif
ac8f6ab3acc9c692ed7c41bd62a0e1e8 file1.jp2-c0-t0-r1.tif
f31bcb01c771f829054cdb013575e86a issue1043.png
f31bcb01c771f829054cdb013575e86a issue1043.png
62bc654c830efddf1b23d6e208447dab tnsot_zero.png
5 changes: 5 additions & 0 deletions tests/nonregression/test_suite.ctest.in
Original file line number Diff line number Diff line change
Expand Up @@ -625,3 +625,8 @@ opj_decompress -i @INPUT_CONF_PATH@/file1.jp2 -o @TEMP_PATH@/file1.jp2-c0-t0-r1.
!opj_decompress -i @INPUT_CONF_PATH@/file1.jp2 -o @TEMP_PATH@/file1.jp2-c10.tif -c 10

opj_decompress -i @INPUT_NR_PATH@/db11217111510058.jp2 -o @TEMP_PATH@/issue1043.png

opj_decompress -i @INPUT_NR_PATH@/tnsot_zero.jp2 -o @TEMP_PATH@/tnsot_zero.png

# try to decompress file with repeated PPT marker
!opj_decompress -i @INPUT_NR_PATH@/oss-fuzz2785.jp2 -o @TEMP_PATH@/oss-fuzz2785.png
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ NR-DEC-kodak_2layers_lrcp.j2c-31-decode-md5
NR-DEC-kodak_2layers_lrcp.j2c-32-decode-md5
NR-DEC-issue135.j2k-68-decode-md5
NR-DEC-db11217111510058.jp2-306-decode-md5
NR-DEC-tnsot_zero.jp2-307-decode-md5
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ NR-DEC-kodak_2layers_lrcp.j2c-31-decode-md5
NR-DEC-kodak_2layers_lrcp.j2c-32-decode-md5
NR-DEC-issue135.j2k-68-decode-md5
NR-DEC-db11217111510058.jp2-306-decode-md5
NR-DEC-tnsot_zero.jp2-307-decode-md5
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ NR-DEC-kodak_2layers_lrcp.j2c-31-decode-md5
NR-DEC-kodak_2layers_lrcp.j2c-32-decode-md5
NR-DEC-issue135.j2k-68-decode-md5
NR-DEC-db11217111510058.jp2-306-decode-md5
NR-DEC-tnsot_zero.jp2-307-decode-md5
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ NR-DEC-kodak_2layers_lrcp.j2c-31-decode-md5
NR-DEC-kodak_2layers_lrcp.j2c-32-decode-md5
NR-DEC-issue135.j2k-68-decode-md5
NR-DEC-db11217111510058.jp2-306-decode-md5
NR-DEC-tnsot_zero.jp2-307-decode-md5