diff -urp a/libopenjpeg/tcd.c b/libopenjpeg/tcd.c --- a/libopenjpeg/tcd.c 2013-01-01 01:01:01.000000000 +0000 +++ b/libopenjpeg/tcd.c 2013-01-01 01:01:01.000000000 +0000 @@ -1360,6 +1360,13 @@ bool tcd_decode_tile(opj_tcd_t *tcd, uns opj_event_msg(tcd->cinfo, EVT_ERROR, "tcd_decode: incomplete bistream\n"); return false; } + + /* The code below assumes that numcomps > 0 */ + if (tile->numcomps <= 0) { + opj_event_msg(tcd->cinfo, EVT_ERROR, "tcd_decode: tile has a zero or negative numcomps\n"); + return true; + } + /*------------------TIER1-----------------*/