Skip to content

Commit

Permalink
Fixed a bug that resulted in the destruction of JP2 box data that had…
Browse files Browse the repository at this point in the history
… never

been constructed in the first place.
  • Loading branch information
mdadams committed Oct 21, 2016
1 parent dfc60c9 commit e24bdc7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/libjasper/jp2/jp2_cod.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ jp2_box_t *jp2_box_get(jas_stream_t *in)
box->info = boxinfo;
box->ops = &boxinfo->ops;
box->len = len;
JAS_DBGLOG(10, (
"preliminary processing of JP2 box: type=%c%s%c (0x%08x); length=%d\n",
'"', boxinfo->name, '"', box->type, box->len
));
if (box->len == 1) {
if (jp2_getuint64(in, &extlen)) {
goto error;
Expand All @@ -282,6 +286,9 @@ jp2_box_t *jp2_box_get(jas_stream_t *in)
goto error;
}
if (jas_stream_copy(tmpstream, in, box->datalen)) {
// Mark the box data as never having been constructed
// so that we will not errantly attempt to destroy it later.
box->ops = &jp2_boxinfo_unk.ops;
jas_eprintf("cannot copy box data\n");
goto error;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libjasper/jp2/jp2_dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jas_image_t *jp2_decode(jas_stream_t *in, char *optstr)
found = 0;
while ((box = jp2_box_get(in))) {
if (jas_getdbglevel() >= 1) {
jas_eprintf("box type %s\n", box->info->name);
jas_eprintf("got box type %s\n", box->info->name);
}
switch (box->type) {
case JP2_BOX_JP2C:
Expand Down

0 comments on commit e24bdc7

Please sign in to comment.