summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--libopenjpeg/j2k.c6
2 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index f7004f2f..92341ad5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,9 @@ What's New for OpenJPEG
+ : added
May 22, 2008
+* [antonin] fixed a bug in j2k.c (j2k_write_sod) that allowed to get negative rates, thanks zhong1985624 for pointing this.
+
+May 22, 2008
* [antonin] additional test to avoid crash due to invalid image size, patch by Christopher Layne
May 20, 2008
diff --git a/libopenjpeg/j2k.c b/libopenjpeg/j2k.c
index bd4a1bd6..563efd68 100644
--- a/libopenjpeg/j2k.c
+++ b/libopenjpeg/j2k.c
@@ -1438,7 +1438,11 @@ static void j2k_write_sod(opj_j2k_t *j2k, void *tile_coder) {
tcp = &cp->tcps[j2k->curtileno];
for (layno = 0; layno < tcp->numlayers; layno++) {
- tcp->rates[layno] -= tcp->rates[layno] ? (j2k->sod_start / (cp->th * cp->tw)) : 0;
+ if (tcp->rates[layno]>(j2k->sod_start / (cp->th * cp->tw))) {
+ tcp->rates[layno]-=(j2k->sod_start / (cp->th * cp->tw));
+ } else if (tcp->rates[layno]) {
+ tcp->rates[layno]=1;
+ }
}
if(j2k->cur_tp_num == 0){
tcd->tcd_image->tiles->packno = 0;