From 8eb481b6c61959e23cefdde5b483813c2f7d15d7 Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Thu, 15 Nov 2012 16:28:44 +0000 Subject: [PATCH] [trunk] add an assert to spot a problem. update issue 189 --- src/lib/openjp2/j2k.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index 495eaaf1..ad8b5b8f 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -5998,8 +5998,13 @@ void opj_j2k_setup_encoder( opj_j2k_t *p_j2k, } else { int res_spec = parameters->res_spec; - int size_prcw = parameters->prcw_init[res_spec - 1] >> (p - (res_spec - 1)); - int size_prch = parameters->prch_init[res_spec - 1] >> (p - (res_spec - 1)); + int size_prcw = 0; + int size_prch = 0; + + assert(res_spec>0); /* issue 189 */ + size_prcw = parameters->prcw_init[res_spec - 1] >> (p - (res_spec - 1)); + size_prch = parameters->prch_init[res_spec - 1] >> (p - (res_spec - 1)); + if (size_prcw < 1) { tccp->prcw[it_res] = 1;