Skip to content

Commit e24bdc7

Browse files
committed
Fixed a bug that resulted in the destruction of JP2 box data that had never
been constructed in the first place.
1 parent dfc60c9 commit e24bdc7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Diff for: src/libjasper/jp2/jp2_cod.c

+7
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ jp2_box_t *jp2_box_get(jas_stream_t *in)
258258
box->info = boxinfo;
259259
box->ops = &boxinfo->ops;
260260
box->len = len;
261+
JAS_DBGLOG(10, (
262+
"preliminary processing of JP2 box: type=%c%s%c (0x%08x); length=%d\n",
263+
'"', boxinfo->name, '"', box->type, box->len
264+
));
261265
if (box->len == 1) {
262266
if (jp2_getuint64(in, &extlen)) {
263267
goto error;
@@ -282,6 +286,9 @@ jp2_box_t *jp2_box_get(jas_stream_t *in)
282286
goto error;
283287
}
284288
if (jas_stream_copy(tmpstream, in, box->datalen)) {
289+
// Mark the box data as never having been constructed
290+
// so that we will not errantly attempt to destroy it later.
291+
box->ops = &jp2_boxinfo_unk.ops;
285292
jas_eprintf("cannot copy box data\n");
286293
goto error;
287294
}

Diff for: src/libjasper/jp2/jp2_dec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ jas_image_t *jp2_decode(jas_stream_t *in, char *optstr)
155155
found = 0;
156156
while ((box = jp2_box_get(in))) {
157157
if (jas_getdbglevel() >= 1) {
158-
jas_eprintf("box type %s\n", box->info->name);
158+
jas_eprintf("got box type %s\n", box->info->name);
159159
}
160160
switch (box->type) {
161161
case JP2_BOX_JP2C:

0 commit comments

Comments
 (0)