diff --git a/data/test/bad/318.jpc b/data/test/bad/318.jpc new file mode 100644 index 00000000..8446ccb3 Binary files /dev/null and b/data/test/bad/318.jpc differ diff --git a/src/libjasper/jpc/jpc_dec.c b/src/libjasper/jpc/jpc_dec.c index e76aa400..125a29ba 100644 --- a/src/libjasper/jpc/jpc_dec.c +++ b/src/libjasper/jpc/jpc_dec.c @@ -611,7 +611,9 @@ static int jpc_dec_process_sod(jpc_dec_t *dec, jpc_ms_t *ms) if (dec->pkthdrstreams) { /* Get the stream containing the packet header data for this tile-part. */ - if (!(tile->pkthdrstream = jpc_streamlist_remove(dec->pkthdrstreams, 0))) { + if (jpc_streamlist_numstreams(dec->pkthdrstreams) != 0 && + !(tile->pkthdrstream = jpc_streamlist_remove(dec->pkthdrstreams, + 0))) { return -1; } }