|
|
425a81 |
https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2008-3520
|
|
|
425a81 |
|
|
|
425a81 |
OpenBSD jas_malloc hardening patches
|
|
|
425a81 |
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/base/jas_cm.c jasper-1.900.1/src/libjasper/base/jas_cm.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/base/jas_cm.c 2007-01-19 22:43:05.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/base/jas_cm.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -704,8 +704,7 @@ static int jas_cmpxformseq_resize(jas_cm
|
|
|
425a81 |
{
|
|
|
425a81 |
jas_cmpxform_t **p;
|
|
|
425a81 |
assert(n >= pxformseq->numpxforms);
|
|
|
425a81 |
- p = (!pxformseq->pxforms) ? jas_malloc(n * sizeof(jas_cmpxform_t *)) :
|
|
|
425a81 |
- jas_realloc(pxformseq->pxforms, n * sizeof(jas_cmpxform_t *));
|
|
|
425a81 |
+ p = jas_realloc2(pxformseq->pxforms, n, sizeof(jas_cmpxform_t *));
|
|
|
425a81 |
if (!p) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -889,13 +888,13 @@ static int jas_cmshapmatlut_set(jas_cmsh
|
|
|
425a81 |
jas_cmshapmatlut_cleanup(lut);
|
|
|
425a81 |
if (curv->numents == 0) {
|
|
|
425a81 |
lut->size = 2;
|
|
|
425a81 |
- if (!(lut->data = jas_malloc(lut->size * sizeof(jas_cmreal_t))))
|
|
|
425a81 |
+ if (!(lut->data = jas_alloc2(lut->size, sizeof(jas_cmreal_t))))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
lut->data[0] = 0.0;
|
|
|
425a81 |
lut->data[1] = 1.0;
|
|
|
425a81 |
} else if (curv->numents == 1) {
|
|
|
425a81 |
lut->size = 256;
|
|
|
425a81 |
- if (!(lut->data = jas_malloc(lut->size * sizeof(jas_cmreal_t))))
|
|
|
425a81 |
+ if (!(lut->data = jas_alloc2(lut->size, sizeof(jas_cmreal_t))))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
gamma = curv->ents[0] / 256.0;
|
|
|
425a81 |
for (i = 0; i < lut->size; ++i) {
|
|
|
425a81 |
@@ -903,7 +902,7 @@ static int jas_cmshapmatlut_set(jas_cmsh
|
|
|
425a81 |
}
|
|
|
425a81 |
} else {
|
|
|
425a81 |
lut->size = curv->numents;
|
|
|
425a81 |
- if (!(lut->data = jas_malloc(lut->size * sizeof(jas_cmreal_t))))
|
|
|
425a81 |
+ if (!(lut->data = jas_alloc2(lut->size, sizeof(jas_cmreal_t))))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
for (i = 0; i < lut->size; ++i) {
|
|
|
425a81 |
lut->data[i] = curv->ents[i] / 65535.0;
|
|
|
425a81 |
@@ -953,7 +952,7 @@ static int jas_cmshapmatlut_invert(jas_c
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
}
|
|
|
425a81 |
- if (!(invlut->data = jas_malloc(n * sizeof(jas_cmreal_t))))
|
|
|
425a81 |
+ if (!(invlut->data = jas_alloc2(n, sizeof(jas_cmreal_t))))
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
invlut->size = n;
|
|
|
425a81 |
for (i = 0; i < invlut->size; ++i) {
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/base/jas_icc.c jasper-1.900.1/src/libjasper/base/jas_icc.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/base/jas_icc.c 2007-01-19 22:43:05.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/base/jas_icc.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -373,7 +373,7 @@ int jas_iccprof_save(jas_iccprof_t *prof
|
|
|
425a81 |
jas_icctagtab_t *tagtab;
|
|
|
425a81 |
|
|
|
425a81 |
tagtab = &prof->tagtab;
|
|
|
425a81 |
- if (!(tagtab->ents = jas_malloc(prof->attrtab->numattrs *
|
|
|
425a81 |
+ if (!(tagtab->ents = jas_alloc2(prof->attrtab->numattrs,
|
|
|
425a81 |
sizeof(jas_icctagtabent_t))))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
tagtab->numents = prof->attrtab->numattrs;
|
|
|
425a81 |
@@ -522,7 +522,7 @@ static int jas_iccprof_gettagtab(jas_str
|
|
|
425a81 |
}
|
|
|
425a81 |
if (jas_iccgetuint32(in, &tagtab->numents))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
- if (!(tagtab->ents = jas_malloc(tagtab->numents *
|
|
|
425a81 |
+ if (!(tagtab->ents = jas_alloc2(tagtab->numents,
|
|
|
425a81 |
sizeof(jas_icctagtabent_t))))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
tagtabent = tagtab->ents;
|
|
|
425a81 |
@@ -743,8 +743,7 @@ static int jas_iccattrtab_resize(jas_icc
|
|
|
425a81 |
{
|
|
|
425a81 |
jas_iccattr_t *newattrs;
|
|
|
425a81 |
assert(maxents >= tab->numattrs);
|
|
|
425a81 |
- newattrs = tab->attrs ? jas_realloc(tab->attrs, maxents *
|
|
|
425a81 |
- sizeof(jas_iccattr_t)) : jas_malloc(maxents * sizeof(jas_iccattr_t));
|
|
|
425a81 |
+ newattrs = jas_realloc2(tab->attrs, maxents, sizeof(jas_iccattr_t));
|
|
|
425a81 |
if (!newattrs)
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
tab->attrs = newattrs;
|
|
|
425a81 |
@@ -999,7 +998,7 @@ static int jas_icccurv_input(jas_iccattr
|
|
|
425a81 |
|
|
|
425a81 |
if (jas_iccgetuint32(in, &curv->numents))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
- if (!(curv->ents = jas_malloc(curv->numents * sizeof(jas_iccuint16_t))))
|
|
|
425a81 |
+ if (!(curv->ents = jas_alloc2(curv->numents, sizeof(jas_iccuint16_t))))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
for (i = 0; i < curv->numents; ++i) {
|
|
|
425a81 |
if (jas_iccgetuint16(in, &curv->ents[i]))
|
|
|
425a81 |
@@ -1100,7 +1099,7 @@ static int jas_icctxtdesc_input(jas_icca
|
|
|
425a81 |
if (jas_iccgetuint32(in, &txtdesc->uclangcode) ||
|
|
|
425a81 |
jas_iccgetuint32(in, &txtdesc->uclen))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
- if (!(txtdesc->ucdata = jas_malloc(txtdesc->uclen * 2)))
|
|
|
425a81 |
+ if (!(txtdesc->ucdata = jas_alloc2(txtdesc->uclen, 2)))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
if (jas_stream_read(in, txtdesc->ucdata, txtdesc->uclen * 2) !=
|
|
|
425a81 |
JAS_CAST(int, txtdesc->uclen * 2))
|
|
|
425a81 |
@@ -1292,17 +1291,17 @@ static int jas_icclut8_input(jas_iccattr
|
|
|
425a81 |
jas_iccgetuint16(in, &lut8->numouttabents))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
clutsize = jas_iccpowi(lut8->clutlen, lut8->numinchans) * lut8->numoutchans;
|
|
|
425a81 |
- if (!(lut8->clut = jas_malloc(clutsize * sizeof(jas_iccuint8_t))) ||
|
|
|
425a81 |
- !(lut8->intabsbuf = jas_malloc(lut8->numinchans *
|
|
|
425a81 |
- lut8->numintabents * sizeof(jas_iccuint8_t))) ||
|
|
|
425a81 |
- !(lut8->intabs = jas_malloc(lut8->numinchans *
|
|
|
425a81 |
+ if (!(lut8->clut = jas_alloc2(clutsize, sizeof(jas_iccuint8_t))) ||
|
|
|
425a81 |
+ !(lut8->intabsbuf = jas_alloc3(lut8->numinchans,
|
|
|
425a81 |
+ lut8->numintabents, sizeof(jas_iccuint8_t))) ||
|
|
|
425a81 |
+ !(lut8->intabs = jas_alloc2(lut8->numinchans,
|
|
|
425a81 |
sizeof(jas_iccuint8_t *))))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
for (i = 0; i < lut8->numinchans; ++i)
|
|
|
425a81 |
lut8->intabs[i] = &lut8->intabsbuf[i * lut8->numintabents];
|
|
|
425a81 |
- if (!(lut8->outtabsbuf = jas_malloc(lut8->numoutchans *
|
|
|
425a81 |
- lut8->numouttabents * sizeof(jas_iccuint8_t))) ||
|
|
|
425a81 |
- !(lut8->outtabs = jas_malloc(lut8->numoutchans *
|
|
|
425a81 |
+ if (!(lut8->outtabsbuf = jas_alloc3(lut8->numoutchans,
|
|
|
425a81 |
+ lut8->numouttabents, sizeof(jas_iccuint8_t))) ||
|
|
|
425a81 |
+ !(lut8->outtabs = jas_alloc2(lut8->numoutchans,
|
|
|
425a81 |
sizeof(jas_iccuint8_t *))))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
for (i = 0; i < lut8->numoutchans; ++i)
|
|
|
425a81 |
@@ -1461,17 +1460,17 @@ static int jas_icclut16_input(jas_iccatt
|
|
|
425a81 |
jas_iccgetuint16(in, &lut16->numouttabents))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
clutsize = jas_iccpowi(lut16->clutlen, lut16->numinchans) * lut16->numoutchans;
|
|
|
425a81 |
- if (!(lut16->clut = jas_malloc(clutsize * sizeof(jas_iccuint16_t))) ||
|
|
|
425a81 |
- !(lut16->intabsbuf = jas_malloc(lut16->numinchans *
|
|
|
425a81 |
- lut16->numintabents * sizeof(jas_iccuint16_t))) ||
|
|
|
425a81 |
- !(lut16->intabs = jas_malloc(lut16->numinchans *
|
|
|
425a81 |
+ if (!(lut16->clut = jas_alloc2(clutsize, sizeof(jas_iccuint16_t))) ||
|
|
|
425a81 |
+ !(lut16->intabsbuf = jas_alloc3(lut16->numinchans,
|
|
|
425a81 |
+ lut16->numintabents, sizeof(jas_iccuint16_t))) ||
|
|
|
425a81 |
+ !(lut16->intabs = jas_alloc2(lut16->numinchans,
|
|
|
425a81 |
sizeof(jas_iccuint16_t *))))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
for (i = 0; i < lut16->numinchans; ++i)
|
|
|
425a81 |
lut16->intabs[i] = &lut16->intabsbuf[i * lut16->numintabents];
|
|
|
425a81 |
- if (!(lut16->outtabsbuf = jas_malloc(lut16->numoutchans *
|
|
|
425a81 |
- lut16->numouttabents * sizeof(jas_iccuint16_t))) ||
|
|
|
425a81 |
- !(lut16->outtabs = jas_malloc(lut16->numoutchans *
|
|
|
425a81 |
+ if (!(lut16->outtabsbuf = jas_alloc3(lut16->numoutchans,
|
|
|
425a81 |
+ lut16->numouttabents, sizeof(jas_iccuint16_t))) ||
|
|
|
425a81 |
+ !(lut16->outtabs = jas_alloc2(lut16->numoutchans,
|
|
|
425a81 |
sizeof(jas_iccuint16_t *))))
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
for (i = 0; i < lut16->numoutchans; ++i)
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/base/jas_image.c jasper-1.900.1/src/libjasper/base/jas_image.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/base/jas_image.c 2007-01-19 22:43:05.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/base/jas_image.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -142,7 +142,7 @@ jas_image_t *jas_image_create(int numcmp
|
|
|
425a81 |
image->inmem_ = true;
|
|
|
425a81 |
|
|
|
425a81 |
/* Allocate memory for the per-component information. */
|
|
|
425a81 |
- if (!(image->cmpts_ = jas_malloc(image->maxcmpts_ *
|
|
|
425a81 |
+ if (!(image->cmpts_ = jas_alloc2(image->maxcmpts_,
|
|
|
425a81 |
sizeof(jas_image_cmpt_t *)))) {
|
|
|
425a81 |
jas_image_destroy(image);
|
|
|
425a81 |
return 0;
|
|
|
425a81 |
@@ -774,8 +774,7 @@ static int jas_image_growcmpts(jas_image
|
|
|
425a81 |
jas_image_cmpt_t **newcmpts;
|
|
|
425a81 |
int cmptno;
|
|
|
425a81 |
|
|
|
425a81 |
- newcmpts = (!image->cmpts_) ? jas_malloc(maxcmpts * sizeof(jas_image_cmpt_t *)) :
|
|
|
425a81 |
- jas_realloc(image->cmpts_, maxcmpts * sizeof(jas_image_cmpt_t *));
|
|
|
425a81 |
+ newcmpts = jas_realloc2(image->cmpts_, maxcmpts, sizeof(jas_image_cmpt_t *));
|
|
|
425a81 |
if (!newcmpts) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/base/jas_malloc.c jasper-1.900.1/src/libjasper/base/jas_malloc.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/base/jas_malloc.c 2007-01-19 22:43:05.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/base/jas_malloc.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -76,6 +76,9 @@
|
|
|
425a81 |
|
|
|
425a81 |
/* We need the prototype for memset. */
|
|
|
425a81 |
#include <string.h>
|
|
|
425a81 |
+#include <limits.h>
|
|
|
425a81 |
+#include <errno.h>
|
|
|
425a81 |
+#include <stdint.h>
|
|
|
425a81 |
|
|
|
425a81 |
#include "jasper/jas_malloc.h"
|
|
|
425a81 |
|
|
|
425a81 |
@@ -113,18 +116,50 @@ void jas_free(void *ptr)
|
|
|
425a81 |
|
|
|
425a81 |
void *jas_realloc(void *ptr, size_t size)
|
|
|
425a81 |
{
|
|
|
425a81 |
- return realloc(ptr, size);
|
|
|
425a81 |
+ return ptr ? realloc(ptr, size) : malloc(size);
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
-void *jas_calloc(size_t nmemb, size_t size)
|
|
|
425a81 |
+void *jas_realloc2(void *ptr, size_t nmemb, size_t size)
|
|
|
425a81 |
+{
|
|
|
425a81 |
+ if (!ptr)
|
|
|
425a81 |
+ return jas_alloc2(nmemb, size);
|
|
|
425a81 |
+ if (nmemb && SIZE_MAX / nmemb < size) {
|
|
|
425a81 |
+ errno = ENOMEM;
|
|
|
425a81 |
+ return NULL;
|
|
|
425a81 |
+ }
|
|
|
425a81 |
+ return jas_realloc(ptr, nmemb * size);
|
|
|
425a81 |
+
|
|
|
425a81 |
+}
|
|
|
425a81 |
+
|
|
|
425a81 |
+void *jas_alloc2(size_t nmemb, size_t size)
|
|
|
425a81 |
+{
|
|
|
425a81 |
+ if (nmemb && SIZE_MAX / nmemb < size) {
|
|
|
425a81 |
+ errno = ENOMEM;
|
|
|
425a81 |
+ return NULL;
|
|
|
425a81 |
+ }
|
|
|
425a81 |
+
|
|
|
425a81 |
+ return jas_malloc(nmemb * size);
|
|
|
425a81 |
+}
|
|
|
425a81 |
+
|
|
|
425a81 |
+void *jas_alloc3(size_t a, size_t b, size_t c)
|
|
|
425a81 |
{
|
|
|
425a81 |
- void *ptr;
|
|
|
425a81 |
size_t n;
|
|
|
425a81 |
- n = nmemb * size;
|
|
|
425a81 |
- if (!(ptr = jas_malloc(n * sizeof(char)))) {
|
|
|
425a81 |
- return 0;
|
|
|
425a81 |
+
|
|
|
425a81 |
+ if (a && SIZE_MAX / a < b) {
|
|
|
425a81 |
+ errno = ENOMEM;
|
|
|
425a81 |
+ return NULL;
|
|
|
425a81 |
}
|
|
|
425a81 |
- memset(ptr, 0, n);
|
|
|
425a81 |
+
|
|
|
425a81 |
+ return jas_alloc2(a*b, c);
|
|
|
425a81 |
+}
|
|
|
425a81 |
+
|
|
|
425a81 |
+void *jas_calloc(size_t nmemb, size_t size)
|
|
|
425a81 |
+{
|
|
|
425a81 |
+ void *ptr;
|
|
|
425a81 |
+
|
|
|
425a81 |
+ ptr = jas_alloc2(nmemb, size);
|
|
|
425a81 |
+ if (ptr)
|
|
|
425a81 |
+ memset(ptr, 0, nmemb*size);
|
|
|
425a81 |
return ptr;
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/base/jas_seq.c jasper-1.900.1/src/libjasper/base/jas_seq.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/base/jas_seq.c 2007-01-19 22:43:05.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/base/jas_seq.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -114,7 +114,7 @@ jas_matrix_t *jas_matrix_create(int numr
|
|
|
425a81 |
matrix->datasize_ = numrows * numcols;
|
|
|
425a81 |
|
|
|
425a81 |
if (matrix->maxrows_ > 0) {
|
|
|
425a81 |
- if (!(matrix->rows_ = jas_malloc(matrix->maxrows_ *
|
|
|
425a81 |
+ if (!(matrix->rows_ = jas_alloc2(matrix->maxrows_,
|
|
|
425a81 |
sizeof(jas_seqent_t *)))) {
|
|
|
425a81 |
jas_matrix_destroy(matrix);
|
|
|
425a81 |
return 0;
|
|
|
425a81 |
@@ -122,7 +122,7 @@ jas_matrix_t *jas_matrix_create(int numr
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
if (matrix->datasize_ > 0) {
|
|
|
425a81 |
- if (!(matrix->data_ = jas_malloc(matrix->datasize_ *
|
|
|
425a81 |
+ if (!(matrix->data_ = jas_alloc2(matrix->datasize_,
|
|
|
425a81 |
sizeof(jas_seqent_t)))) {
|
|
|
425a81 |
jas_matrix_destroy(matrix);
|
|
|
425a81 |
return 0;
|
|
|
425a81 |
@@ -220,7 +220,7 @@ void jas_matrix_bindsub(jas_matrix_t *ma
|
|
|
425a81 |
mat0->numrows_ = r1 - r0 + 1;
|
|
|
425a81 |
mat0->numcols_ = c1 - c0 + 1;
|
|
|
425a81 |
mat0->maxrows_ = mat0->numrows_;
|
|
|
425a81 |
- mat0->rows_ = jas_malloc(mat0->maxrows_ * sizeof(jas_seqent_t *));
|
|
|
425a81 |
+ mat0->rows_ = jas_alloc2(mat0->maxrows_, sizeof(jas_seqent_t *));
|
|
|
425a81 |
for (i = 0; i < mat0->numrows_; ++i) {
|
|
|
425a81 |
mat0->rows_[i] = mat1->rows_[r0 + i] + c0;
|
|
|
425a81 |
}
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/base/jas_stream.c jasper-1.900.1/src/libjasper/base/jas_stream.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/base/jas_stream.c 2007-01-19 22:43:05.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/base/jas_stream.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -212,7 +212,7 @@ jas_stream_t *jas_stream_memopen(char *b
|
|
|
425a81 |
if (buf) {
|
|
|
425a81 |
obj->buf_ = (unsigned char *) buf;
|
|
|
425a81 |
} else {
|
|
|
425a81 |
- obj->buf_ = jas_malloc(obj->bufsize_ * sizeof(char));
|
|
|
425a81 |
+ obj->buf_ = jas_malloc(obj->bufsize_);
|
|
|
425a81 |
obj->myalloc_ = 1;
|
|
|
425a81 |
}
|
|
|
425a81 |
if (!obj->buf_) {
|
|
|
425a81 |
@@ -992,7 +992,7 @@ static int mem_resize(jas_stream_memobj_
|
|
|
425a81 |
unsigned char *buf;
|
|
|
425a81 |
|
|
|
425a81 |
assert(m->buf_);
|
|
|
425a81 |
- if (!(buf = jas_realloc(m->buf_, bufsize * sizeof(unsigned char)))) {
|
|
|
425a81 |
+ if (!(buf = jas_realloc(m->buf_, bufsize))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
m->buf_ = buf;
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/bmp/bmp_dec.c jasper-1.900.1/src/libjasper/bmp/bmp_dec.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/bmp/bmp_dec.c 2007-01-19 22:43:07.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/bmp/bmp_dec.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -283,7 +283,7 @@ static bmp_info_t *bmp_getinfo(jas_strea
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
if (info->numcolors > 0) {
|
|
|
425a81 |
- if (!(info->palents = jas_malloc(info->numcolors *
|
|
|
425a81 |
+ if (!(info->palents = jas_alloc2(info->numcolors,
|
|
|
425a81 |
sizeof(bmp_palent_t)))) {
|
|
|
425a81 |
bmp_info_destroy(info);
|
|
|
425a81 |
return 0;
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/include/jasper/jas_malloc.h jasper-1.900.1/src/libjasper/include/jasper/jas_malloc.h
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/include/jasper/jas_malloc.h 2007-01-19 22:43:04.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/include/jasper/jas_malloc.h 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -95,6 +95,9 @@ extern "C" {
|
|
|
425a81 |
#define jas_free MEMFREE
|
|
|
425a81 |
#define jas_realloc MEMREALLOC
|
|
|
425a81 |
#define jas_calloc MEMCALLOC
|
|
|
425a81 |
+#define jas_alloc2(a, b) MEMALLOC((a)*(b))
|
|
|
425a81 |
+#define jas_alloc3(a, b, c) MEMALLOC((a)*(b)*(c))
|
|
|
425a81 |
+#define jas_realloc2(p, a, b) MEMREALLOC((p), (a)*(b))
|
|
|
425a81 |
#endif
|
|
|
425a81 |
|
|
|
425a81 |
/******************************************************************************\
|
|
|
425a81 |
@@ -115,6 +118,12 @@ void *jas_realloc(void *ptr, size_t size
|
|
|
425a81 |
/* Allocate a block of memory and initialize the contents to zero. */
|
|
|
425a81 |
void *jas_calloc(size_t nmemb, size_t size);
|
|
|
425a81 |
|
|
|
425a81 |
+/* size-checked double allocation .*/
|
|
|
425a81 |
+void *jas_alloc2(size_t, size_t);
|
|
|
425a81 |
+
|
|
|
425a81 |
+void *jas_alloc3(size_t, size_t, size_t);
|
|
|
425a81 |
+
|
|
|
425a81 |
+void *jas_realloc2(void *, size_t, size_t);
|
|
|
425a81 |
#endif
|
|
|
425a81 |
|
|
|
425a81 |
#ifdef __cplusplus
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/jp2/jp2_cod.c jasper-1.900.1/src/libjasper/jp2/jp2_cod.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/jp2/jp2_cod.c 2007-01-19 22:43:05.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/jp2/jp2_cod.c 2009-10-22 10:30:24.000000000 +0200
|
|
|
425a81 |
@@ -247,7 +247,7 @@ jp2_box_t *jp2_box_get(jas_stream_t *in)
|
|
|
425a81 |
box = 0;
|
|
|
425a81 |
tmpstream = 0;
|
|
|
425a81 |
|
|
|
425a81 |
- if (!(box = jas_malloc(sizeof(jp2_box_t)))) {
|
|
|
425a81 |
+ if (!(box = jas_calloc(1, sizeof(jp2_box_t)))) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
box->ops = &jp2_boxinfo_unk.ops;
|
|
|
425a81 |
@@ -372,7 +372,7 @@ static int jp2_bpcc_getdata(jp2_box_t *b
|
|
|
425a81 |
jp2_bpcc_t *bpcc = &box->data.bpcc;
|
|
|
425a81 |
unsigned int i;
|
|
|
425a81 |
bpcc->numcmpts = box->datalen;
|
|
|
425a81 |
- if (!(bpcc->bpcs = jas_malloc(bpcc->numcmpts * sizeof(uint_fast8_t)))) {
|
|
|
425a81 |
+ if (!(bpcc->bpcs = jas_alloc2(bpcc->numcmpts, sizeof(uint_fast8_t)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
for (i = 0; i < bpcc->numcmpts; ++i) {
|
|
|
425a81 |
@@ -416,7 +416,7 @@ static int jp2_colr_getdata(jp2_box_t *b
|
|
|
425a81 |
break;
|
|
|
425a81 |
case JP2_COLR_ICC:
|
|
|
425a81 |
colr->iccplen = box->datalen - 3;
|
|
|
425a81 |
- if (!(colr->iccp = jas_malloc(colr->iccplen * sizeof(uint_fast8_t)))) {
|
|
|
425a81 |
+ if (!(colr->iccp = jas_alloc2(colr->iccplen, sizeof(uint_fast8_t)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
if (jas_stream_read(in, colr->iccp, colr->iccplen) != colr->iccplen) {
|
|
|
425a81 |
@@ -453,7 +453,7 @@ static int jp2_cdef_getdata(jp2_box_t *b
|
|
|
425a81 |
if (jp2_getuint16(in, &cdef->numchans)) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
- if (!(cdef->ents = jas_malloc(cdef->numchans * sizeof(jp2_cdefchan_t)))) {
|
|
|
425a81 |
+ if (!(cdef->ents = jas_alloc2(cdef->numchans, sizeof(jp2_cdefchan_t)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
for (channo = 0; channo < cdef->numchans; ++channo) {
|
|
|
425a81 |
@@ -766,7 +766,7 @@ static int jp2_cmap_getdata(jp2_box_t *b
|
|
|
425a81 |
unsigned int i;
|
|
|
425a81 |
|
|
|
425a81 |
cmap->numchans = (box->datalen) / 4;
|
|
|
425a81 |
- if (!(cmap->ents = jas_malloc(cmap->numchans * sizeof(jp2_cmapent_t)))) {
|
|
|
425a81 |
+ if (!(cmap->ents = jas_alloc2(cmap->numchans, sizeof(jp2_cmapent_t)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
for (i = 0; i < cmap->numchans; ++i) {
|
|
|
425a81 |
@@ -828,10 +828,10 @@ static int jp2_pclr_getdata(jp2_box_t *b
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
lutsize = pclr->numlutents * pclr->numchans;
|
|
|
425a81 |
- if (!(pclr->lutdata = jas_malloc(lutsize * sizeof(int_fast32_t)))) {
|
|
|
425a81 |
+ if (!(pclr->lutdata = jas_alloc2(lutsize, sizeof(int_fast32_t)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
- if (!(pclr->bpc = jas_malloc(pclr->numchans * sizeof(uint_fast8_t)))) {
|
|
|
425a81 |
+ if (!(pclr->bpc = jas_alloc2(pclr->numchans, sizeof(uint_fast8_t)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
for (i = 0; i < pclr->numchans; ++i) {
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/jp2/jp2_dec.c jasper-1.900.1/src/libjasper/jp2/jp2_dec.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/jp2/jp2_dec.c 2007-01-19 22:43:05.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/jp2/jp2_dec.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -336,7 +336,7 @@ jas_image_t *jp2_decode(jas_stream_t *in
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
/* Allocate space for the channel-number to component-number LUT. */
|
|
|
425a81 |
- if (!(dec->chantocmptlut = jas_malloc(dec->numchans * sizeof(uint_fast16_t)))) {
|
|
|
425a81 |
+ if (!(dec->chantocmptlut = jas_alloc2(dec->numchans, sizeof(uint_fast16_t)))) {
|
|
|
425a81 |
jas_eprintf("error: no memory\n");
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -354,7 +354,7 @@ jas_image_t *jp2_decode(jas_stream_t *in
|
|
|
425a81 |
if (cmapent->map == JP2_CMAP_DIRECT) {
|
|
|
425a81 |
dec->chantocmptlut[channo] = channo;
|
|
|
425a81 |
} else if (cmapent->map == JP2_CMAP_PALETTE) {
|
|
|
425a81 |
- lutents = jas_malloc(pclrd->numlutents * sizeof(int_fast32_t));
|
|
|
425a81 |
+ lutents = jas_alloc2(pclrd->numlutents, sizeof(int_fast32_t));
|
|
|
425a81 |
for (i = 0; i < pclrd->numlutents; ++i) {
|
|
|
425a81 |
lutents[i] = pclrd->lutdata[cmapent->pcol + i * pclrd->numchans];
|
|
|
425a81 |
}
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/jp2/jp2_enc.c jasper-1.900.1/src/libjasper/jp2/jp2_enc.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/jp2/jp2_enc.c 2007-01-19 22:43:05.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/jp2/jp2_enc.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -191,7 +191,7 @@ int sgnd;
|
|
|
425a81 |
}
|
|
|
425a81 |
bpcc = &box->data.bpcc;
|
|
|
425a81 |
bpcc->numcmpts = jas_image_numcmpts(image);
|
|
|
425a81 |
- if (!(bpcc->bpcs = jas_malloc(bpcc->numcmpts *
|
|
|
425a81 |
+ if (!(bpcc->bpcs = jas_alloc2(bpcc->numcmpts,
|
|
|
425a81 |
sizeof(uint_fast8_t)))) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -285,7 +285,7 @@ int sgnd;
|
|
|
425a81 |
}
|
|
|
425a81 |
cdef = &box->data.cdef;
|
|
|
425a81 |
cdef->numchans = jas_image_numcmpts(image);
|
|
|
425a81 |
- cdef->ents = jas_malloc(cdef->numchans * sizeof(jp2_cdefchan_t));
|
|
|
425a81 |
+ cdef->ents = jas_alloc2(cdef->numchans, sizeof(jp2_cdefchan_t));
|
|
|
425a81 |
for (i = 0; i < jas_image_numcmpts(image); ++i) {
|
|
|
425a81 |
cdefchanent = &cdef->ents[i];
|
|
|
425a81 |
cdefchanent->channo = i;
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/jpc/jpc_cs.c jasper-1.900.1/src/libjasper/jpc/jpc_cs.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/jpc/jpc_cs.c 2009-10-22 09:58:16.000000000 +0200
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/jpc/jpc_cs.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -502,7 +502,7 @@ static int jpc_siz_getparms(jpc_ms_t *ms
|
|
|
425a81 |
!siz->tileheight || !siz->numcomps) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
- if (!(siz->comps = jas_malloc(siz->numcomps * sizeof(jpc_sizcomp_t)))) {
|
|
|
425a81 |
+ if (!(siz->comps = jas_alloc2(siz->numcomps, sizeof(jpc_sizcomp_t)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
for (i = 0; i < siz->numcomps; ++i) {
|
|
|
425a81 |
@@ -986,7 +986,7 @@ static int jpc_qcx_getcompparms(jpc_qcxc
|
|
|
425a81 |
jpc_qcx_destroycompparms(compparms);
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
} else if (compparms->numstepsizes > 0) {
|
|
|
425a81 |
- compparms->stepsizes = jas_malloc(compparms->numstepsizes *
|
|
|
425a81 |
+ compparms->stepsizes = jas_alloc2(compparms->numstepsizes,
|
|
|
425a81 |
sizeof(uint_fast16_t));
|
|
|
425a81 |
assert(compparms->stepsizes);
|
|
|
425a81 |
for (i = 0; i < compparms->numstepsizes; ++i) {
|
|
|
425a81 |
@@ -1094,7 +1094,7 @@ static int jpc_ppm_getparms(jpc_ms_t *ms
|
|
|
425a81 |
|
|
|
425a81 |
ppm->len = ms->len - 1;
|
|
|
425a81 |
if (ppm->len > 0) {
|
|
|
425a81 |
- if (!(ppm->data = jas_malloc(ppm->len * sizeof(unsigned char)))) {
|
|
|
425a81 |
+ if (!(ppm->data = jas_malloc(ppm->len))) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
if (JAS_CAST(uint, jas_stream_read(in, ppm->data, ppm->len)) != ppm->len) {
|
|
|
425a81 |
@@ -1163,7 +1163,7 @@ static int jpc_ppt_getparms(jpc_ms_t *ms
|
|
|
425a81 |
}
|
|
|
425a81 |
ppt->len = ms->len - 1;
|
|
|
425a81 |
if (ppt->len > 0) {
|
|
|
425a81 |
- if (!(ppt->data = jas_malloc(ppt->len * sizeof(unsigned char)))) {
|
|
|
425a81 |
+ if (!(ppt->data = jas_malloc(ppt->len))) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
if (jas_stream_read(in, (char *) ppt->data, ppt->len) != JAS_CAST(int, ppt->len)) {
|
|
|
425a81 |
@@ -1226,7 +1226,7 @@ static int jpc_poc_getparms(jpc_ms_t *ms
|
|
|
425a81 |
uint_fast8_t tmp;
|
|
|
425a81 |
poc->numpchgs = (cstate->numcomps > 256) ? (ms->len / 9) :
|
|
|
425a81 |
(ms->len / 7);
|
|
|
425a81 |
- if (!(poc->pchgs = jas_malloc(poc->numpchgs * sizeof(jpc_pocpchg_t)))) {
|
|
|
425a81 |
+ if (!(poc->pchgs = jas_alloc2(poc->numpchgs, sizeof(jpc_pocpchg_t)))) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
for (pchgno = 0, pchg = poc->pchgs; pchgno < poc->numpchgs; ++pchgno,
|
|
|
425a81 |
@@ -1331,7 +1331,7 @@ static int jpc_crg_getparms(jpc_ms_t *ms
|
|
|
425a81 |
jpc_crgcomp_t *comp;
|
|
|
425a81 |
uint_fast16_t compno;
|
|
|
425a81 |
crg->numcomps = cstate->numcomps;
|
|
|
425a81 |
- if (!(crg->comps = jas_malloc(cstate->numcomps * sizeof(uint_fast16_t)))) {
|
|
|
425a81 |
+ if (!(crg->comps = jas_alloc2(cstate->numcomps, sizeof(uint_fast16_t)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
for (compno = 0, comp = crg->comps; compno < cstate->numcomps;
|
|
|
425a81 |
@@ -1470,7 +1470,7 @@ static int jpc_unk_getparms(jpc_ms_t *ms
|
|
|
425a81 |
cstate = 0;
|
|
|
425a81 |
|
|
|
425a81 |
if (ms->len > 0) {
|
|
|
425a81 |
- if (!(unk->data = jas_malloc(ms->len * sizeof(unsigned char)))) {
|
|
|
425a81 |
+ if (!(unk->data = jas_malloc(ms->len))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
if (jas_stream_read(in, (char *) unk->data, ms->len) != JAS_CAST(int, ms->len)) {
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/jpc/jpc_dec.c jasper-1.900.1/src/libjasper/jpc/jpc_dec.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/jpc/jpc_dec.c 2009-10-22 09:58:16.000000000 +0200
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/jpc/jpc_dec.c 2009-10-22 10:30:50.000000000 +0200
|
|
|
425a81 |
@@ -449,7 +449,7 @@ static int jpc_dec_process_sot(jpc_dec_t
|
|
|
425a81 |
|
|
|
425a81 |
if (dec->state == JPC_MH) {
|
|
|
425a81 |
|
|
|
425a81 |
- compinfos = jas_malloc(dec->numcomps * sizeof(jas_image_cmptparm_t));
|
|
|
425a81 |
+ compinfos = jas_alloc2(dec->numcomps, sizeof(jas_image_cmptparm_t));
|
|
|
425a81 |
assert(compinfos);
|
|
|
425a81 |
for (cmptno = 0, cmpt = dec->cmpts, compinfo = compinfos;
|
|
|
425a81 |
cmptno < dec->numcomps; ++cmptno, ++cmpt, ++compinfo) {
|
|
|
425a81 |
@@ -692,7 +692,7 @@ static int jpc_dec_tileinit(jpc_dec_t *d
|
|
|
425a81 |
tile->realmode = 1;
|
|
|
425a81 |
}
|
|
|
425a81 |
tcomp->numrlvls = ccp->numrlvls;
|
|
|
425a81 |
- if (!(tcomp->rlvls = jas_malloc(tcomp->numrlvls *
|
|
|
425a81 |
+ if (!(tcomp->rlvls = jas_alloc2(tcomp->numrlvls,
|
|
|
425a81 |
sizeof(jpc_dec_rlvl_t)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -764,7 +764,7 @@ rlvl->bands = 0;
|
|
|
425a81 |
rlvl->cbgheightexpn);
|
|
|
425a81 |
|
|
|
425a81 |
rlvl->numbands = (!rlvlno) ? 1 : 3;
|
|
|
425a81 |
- if (!(rlvl->bands = jas_malloc(rlvl->numbands *
|
|
|
425a81 |
+ if (!(rlvl->bands = jas_alloc2(rlvl->numbands,
|
|
|
425a81 |
sizeof(jpc_dec_band_t)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -797,7 +797,7 @@ rlvl->bands = 0;
|
|
|
425a81 |
|
|
|
425a81 |
assert(rlvl->numprcs);
|
|
|
425a81 |
|
|
|
425a81 |
- if (!(band->prcs = jas_malloc(rlvl->numprcs * sizeof(jpc_dec_prc_t)))) {
|
|
|
425a81 |
+ if (!(band->prcs = jas_alloc2(rlvl->numprcs, sizeof(jpc_dec_prc_t)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
@@ -834,7 +834,7 @@ rlvl->bands = 0;
|
|
|
425a81 |
if (!(prc->numimsbstagtree = jpc_tagtree_create(prc->numhcblks, prc->numvcblks))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
- if (!(prc->cblks = jas_malloc(prc->numcblks * sizeof(jpc_dec_cblk_t)))) {
|
|
|
425a81 |
+ if (!(prc->cblks = jas_alloc2(prc->numcblks, sizeof(jpc_dec_cblk_t)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
@@ -1181,7 +1181,7 @@ static int jpc_dec_process_siz(jpc_dec_t
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
- if (!(dec->cmpts = jas_malloc(dec->numcomps * sizeof(jpc_dec_cmpt_t)))) {
|
|
|
425a81 |
+ if (!(dec->cmpts = jas_alloc2(dec->numcomps, sizeof(jpc_dec_cmpt_t)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
@@ -1204,7 +1204,7 @@ static int jpc_dec_process_siz(jpc_dec_t
|
|
|
425a81 |
dec->numhtiles = JPC_CEILDIV(dec->xend - dec->tilexoff, dec->tilewidth);
|
|
|
425a81 |
dec->numvtiles = JPC_CEILDIV(dec->yend - dec->tileyoff, dec->tileheight);
|
|
|
425a81 |
dec->numtiles = dec->numhtiles * dec->numvtiles;
|
|
|
425a81 |
- if (!(dec->tiles = jas_malloc(dec->numtiles * sizeof(jpc_dec_tile_t)))) {
|
|
|
425a81 |
+ if (!(dec->tiles = jas_calloc(dec->numtiles, sizeof(jpc_dec_tile_t)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
@@ -1228,7 +1228,7 @@ static int jpc_dec_process_siz(jpc_dec_t
|
|
|
425a81 |
tile->pkthdrstreampos = 0;
|
|
|
425a81 |
tile->pptstab = 0;
|
|
|
425a81 |
tile->cp = 0;
|
|
|
425a81 |
- if (!(tile->tcomps = jas_malloc(dec->numcomps *
|
|
|
425a81 |
+ if (!(tile->tcomps = jas_calloc(dec->numcomps,
|
|
|
425a81 |
sizeof(jpc_dec_tcomp_t)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -1489,7 +1489,7 @@ static jpc_dec_cp_t *jpc_dec_cp_create(u
|
|
|
425a81 |
cp->numlyrs = 0;
|
|
|
425a81 |
cp->mctid = 0;
|
|
|
425a81 |
cp->csty = 0;
|
|
|
425a81 |
- if (!(cp->ccps = jas_malloc(cp->numcomps * sizeof(jpc_dec_ccp_t)))) {
|
|
|
425a81 |
+ if (!(cp->ccps = jas_alloc2(cp->numcomps, sizeof(jpc_dec_ccp_t)))) {
|
|
|
425a81 |
return 0;
|
|
|
425a81 |
}
|
|
|
425a81 |
if (!(cp->pchglist = jpc_pchglist_create())) {
|
|
|
425a81 |
@@ -2048,7 +2048,7 @@ jpc_streamlist_t *jpc_streamlist_create(
|
|
|
425a81 |
}
|
|
|
425a81 |
streamlist->numstreams = 0;
|
|
|
425a81 |
streamlist->maxstreams = 100;
|
|
|
425a81 |
- if (!(streamlist->streams = jas_malloc(streamlist->maxstreams *
|
|
|
425a81 |
+ if (!(streamlist->streams = jas_alloc2(streamlist->maxstreams,
|
|
|
425a81 |
sizeof(jas_stream_t *)))) {
|
|
|
425a81 |
jas_free(streamlist);
|
|
|
425a81 |
return 0;
|
|
|
425a81 |
@@ -2068,8 +2068,8 @@ int jpc_streamlist_insert(jpc_streamlist
|
|
|
425a81 |
/* Grow the array of streams if necessary. */
|
|
|
425a81 |
if (streamlist->numstreams >= streamlist->maxstreams) {
|
|
|
425a81 |
newmaxstreams = streamlist->maxstreams + 1024;
|
|
|
425a81 |
- if (!(newstreams = jas_realloc(streamlist->streams,
|
|
|
425a81 |
- (newmaxstreams + 1024) * sizeof(jas_stream_t *)))) {
|
|
|
425a81 |
+ if (!(newstreams = jas_realloc2(streamlist->streams,
|
|
|
425a81 |
+ (newmaxstreams + 1024), sizeof(jas_stream_t *)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
for (i = streamlist->numstreams; i < streamlist->maxstreams; ++i) {
|
|
|
425a81 |
@@ -2155,8 +2155,7 @@ int jpc_ppxstab_grow(jpc_ppxstab_t *tab,
|
|
|
425a81 |
{
|
|
|
425a81 |
jpc_ppxstabent_t **newents;
|
|
|
425a81 |
if (tab->maxents < maxents) {
|
|
|
425a81 |
- newents = (tab->ents) ? jas_realloc(tab->ents, maxents *
|
|
|
425a81 |
- sizeof(jpc_ppxstabent_t *)) : jas_malloc(maxents * sizeof(jpc_ppxstabent_t *));
|
|
|
425a81 |
+ newents = jas_realloc2(tab->ents, maxents, sizeof(jpc_ppxstabent_t *));
|
|
|
425a81 |
if (!newents) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/jpc/jpc_enc.c jasper-1.900.1/src/libjasper/jpc/jpc_enc.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/jpc/jpc_enc.c 2007-01-19 22:43:07.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/jpc/jpc_enc.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -403,7 +403,7 @@ static jpc_enc_cp_t *cp_create(char *opt
|
|
|
425a81 |
vsteplcm *= jas_image_cmptvstep(image, cmptno);
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
- if (!(cp->ccps = jas_malloc(cp->numcmpts * sizeof(jpc_enc_ccp_t)))) {
|
|
|
425a81 |
+ if (!(cp->ccps = jas_alloc2(cp->numcmpts, sizeof(jpc_enc_ccp_t)))) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
for (cmptno = 0, ccp = cp->ccps; cmptno < JAS_CAST(int, cp->numcmpts); ++cmptno,
|
|
|
425a81 |
@@ -656,7 +656,7 @@ static jpc_enc_cp_t *cp_create(char *opt
|
|
|
425a81 |
|
|
|
425a81 |
if (ilyrrates && numilyrrates > 0) {
|
|
|
425a81 |
tcp->numlyrs = numilyrrates + 1;
|
|
|
425a81 |
- if (!(tcp->ilyrrates = jas_malloc((tcp->numlyrs - 1) *
|
|
|
425a81 |
+ if (!(tcp->ilyrrates = jas_alloc2((tcp->numlyrs - 1),
|
|
|
425a81 |
sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -940,7 +940,7 @@ startoff = jas_stream_getrwcount(enc->ou
|
|
|
425a81 |
siz->tilewidth = cp->tilewidth;
|
|
|
425a81 |
siz->tileheight = cp->tileheight;
|
|
|
425a81 |
siz->numcomps = cp->numcmpts;
|
|
|
425a81 |
- siz->comps = jas_malloc(siz->numcomps * sizeof(jpc_sizcomp_t));
|
|
|
425a81 |
+ siz->comps = jas_alloc2(siz->numcomps, sizeof(jpc_sizcomp_t));
|
|
|
425a81 |
assert(siz->comps);
|
|
|
425a81 |
for (i = 0; i < JAS_CAST(int, cp->numcmpts); ++i) {
|
|
|
425a81 |
siz->comps[i].prec = cp->ccps[i].prec;
|
|
|
425a81 |
@@ -977,7 +977,7 @@ startoff = jas_stream_getrwcount(enc->ou
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
crg = &enc->mrk->parms.crg;
|
|
|
425a81 |
- crg->comps = jas_malloc(crg->numcomps * sizeof(jpc_crgcomp_t));
|
|
|
425a81 |
+ crg->comps = jas_alloc2(crg->numcomps, sizeof(jpc_crgcomp_t));
|
|
|
425a81 |
if (jpc_putms(enc->out, enc->cstate, enc->mrk)) {
|
|
|
425a81 |
jas_eprintf("cannot write CRG marker\n");
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
@@ -1955,7 +1955,7 @@ jpc_enc_tile_t *jpc_enc_tile_create(jpc_
|
|
|
425a81 |
tile->mctid = cp->tcp.mctid;
|
|
|
425a81 |
|
|
|
425a81 |
tile->numlyrs = cp->tcp.numlyrs;
|
|
|
425a81 |
- if (!(tile->lyrsizes = jas_malloc(tile->numlyrs *
|
|
|
425a81 |
+ if (!(tile->lyrsizes = jas_alloc2(tile->numlyrs,
|
|
|
425a81 |
sizeof(uint_fast32_t)))) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -1964,7 +1964,7 @@ jpc_enc_tile_t *jpc_enc_tile_create(jpc_
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
/* Allocate an array for the per-tile-component information. */
|
|
|
425a81 |
- if (!(tile->tcmpts = jas_malloc(cp->numcmpts * sizeof(jpc_enc_tcmpt_t)))) {
|
|
|
425a81 |
+ if (!(tile->tcmpts = jas_alloc2(cp->numcmpts, sizeof(jpc_enc_tcmpt_t)))) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
/* Initialize a few members critical for error recovery. */
|
|
|
425a81 |
@@ -2110,7 +2110,7 @@ static jpc_enc_tcmpt_t *tcmpt_create(jpc
|
|
|
425a81 |
jas_seq2d_ystart(tcmpt->data), jas_seq2d_xend(tcmpt->data),
|
|
|
425a81 |
jas_seq2d_yend(tcmpt->data), bandinfos);
|
|
|
425a81 |
|
|
|
425a81 |
- if (!(tcmpt->rlvls = jas_malloc(tcmpt->numrlvls * sizeof(jpc_enc_rlvl_t)))) {
|
|
|
425a81 |
+ if (!(tcmpt->rlvls = jas_alloc2(tcmpt->numrlvls, sizeof(jpc_enc_rlvl_t)))) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
for (rlvlno = 0, rlvl = tcmpt->rlvls; rlvlno < tcmpt->numrlvls;
|
|
|
425a81 |
@@ -2213,7 +2213,7 @@ static jpc_enc_rlvl_t *rlvl_create(jpc_e
|
|
|
425a81 |
rlvl->numvprcs = JPC_FLOORDIVPOW2(brprcbry - tlprctly, rlvl->prcheightexpn);
|
|
|
425a81 |
rlvl->numprcs = rlvl->numhprcs * rlvl->numvprcs;
|
|
|
425a81 |
|
|
|
425a81 |
- if (!(rlvl->bands = jas_malloc(rlvl->numbands * sizeof(jpc_enc_band_t)))) {
|
|
|
425a81 |
+ if (!(rlvl->bands = jas_alloc2(rlvl->numbands, sizeof(jpc_enc_band_t)))) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands;
|
|
|
425a81 |
@@ -2290,7 +2290,7 @@ if (bandinfo->xstart != bandinfo->xend &
|
|
|
425a81 |
band->synweight = bandinfo->synenergywt;
|
|
|
425a81 |
|
|
|
425a81 |
if (band->data) {
|
|
|
425a81 |
- if (!(band->prcs = jas_malloc(rlvl->numprcs * sizeof(jpc_enc_prc_t)))) {
|
|
|
425a81 |
+ if (!(band->prcs = jas_alloc2(rlvl->numprcs, sizeof(jpc_enc_prc_t)))) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
for (prcno = 0, prc = band->prcs; prcno < rlvl->numprcs; ++prcno,
|
|
|
425a81 |
@@ -2422,7 +2422,7 @@ if (!rlvlno) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
- if (!(prc->cblks = jas_malloc(prc->numcblks * sizeof(jpc_enc_cblk_t)))) {
|
|
|
425a81 |
+ if (!(prc->cblks = jas_alloc2(prc->numcblks, sizeof(jpc_enc_cblk_t)))) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks;
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/jpc/jpc_mqdec.c jasper-1.900.1/src/libjasper/jpc/jpc_mqdec.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/jpc/jpc_mqdec.c 2007-01-19 22:43:07.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/jpc/jpc_mqdec.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -118,7 +118,7 @@ jpc_mqdec_t *jpc_mqdec_create(int maxctx
|
|
|
425a81 |
mqdec->in = in;
|
|
|
425a81 |
mqdec->maxctxs = maxctxs;
|
|
|
425a81 |
/* Allocate memory for the per-context state information. */
|
|
|
425a81 |
- if (!(mqdec->ctxs = jas_malloc(mqdec->maxctxs * sizeof(jpc_mqstate_t *)))) {
|
|
|
425a81 |
+ if (!(mqdec->ctxs = jas_alloc2(mqdec->maxctxs, sizeof(jpc_mqstate_t *)))) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
/* Set the current context to the first context. */
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/jpc/jpc_mqenc.c jasper-1.900.1/src/libjasper/jpc/jpc_mqenc.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/jpc/jpc_mqenc.c 2007-01-19 22:43:07.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/jpc/jpc_mqenc.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -197,7 +197,7 @@ jpc_mqenc_t *jpc_mqenc_create(int maxctx
|
|
|
425a81 |
mqenc->maxctxs = maxctxs;
|
|
|
425a81 |
|
|
|
425a81 |
/* Allocate memory for the per-context state information. */
|
|
|
425a81 |
- if (!(mqenc->ctxs = jas_malloc(mqenc->maxctxs * sizeof(jpc_mqstate_t *)))) {
|
|
|
425a81 |
+ if (!(mqenc->ctxs = jas_alloc2(mqenc->maxctxs, sizeof(jpc_mqstate_t *)))) {
|
|
|
425a81 |
goto error;
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/jpc/jpc_qmfb.c jasper-1.900.1/src/libjasper/jpc/jpc_qmfb.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/jpc/jpc_qmfb.c 2007-01-19 22:43:07.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/jpc/jpc_qmfb.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -321,7 +321,7 @@ void jpc_qmfb_split_row(jpc_fix_t *a, in
|
|
|
425a81 |
#if !defined(HAVE_VLA)
|
|
|
425a81 |
/* Get a buffer. */
|
|
|
425a81 |
if (bufsize > QMFB_SPLITBUFSIZE) {
|
|
|
425a81 |
- if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
+ if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
/* We have no choice but to commit suicide in this case. */
|
|
|
425a81 |
abort();
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -389,7 +389,7 @@ void jpc_qmfb_split_col(jpc_fix_t *a, in
|
|
|
425a81 |
#if !defined(HAVE_VLA)
|
|
|
425a81 |
/* Get a buffer. */
|
|
|
425a81 |
if (bufsize > QMFB_SPLITBUFSIZE) {
|
|
|
425a81 |
- if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
+ if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
/* We have no choice but to commit suicide in this case. */
|
|
|
425a81 |
abort();
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -460,7 +460,7 @@ void jpc_qmfb_split_colgrp(jpc_fix_t *a,
|
|
|
425a81 |
#if !defined(HAVE_VLA)
|
|
|
425a81 |
/* Get a buffer. */
|
|
|
425a81 |
if (bufsize > QMFB_SPLITBUFSIZE) {
|
|
|
425a81 |
- if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
+ if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
/* We have no choice but to commit suicide in this case. */
|
|
|
425a81 |
abort();
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -549,7 +549,7 @@ void jpc_qmfb_split_colres(jpc_fix_t *a,
|
|
|
425a81 |
#if !defined(HAVE_VLA)
|
|
|
425a81 |
/* Get a buffer. */
|
|
|
425a81 |
if (bufsize > QMFB_SPLITBUFSIZE) {
|
|
|
425a81 |
- if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
+ if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
/* We have no choice but to commit suicide in this case. */
|
|
|
425a81 |
abort();
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -633,7 +633,7 @@ void jpc_qmfb_join_row(jpc_fix_t *a, int
|
|
|
425a81 |
#if !defined(HAVE_VLA)
|
|
|
425a81 |
/* Allocate memory for the join buffer from the heap. */
|
|
|
425a81 |
if (bufsize > QMFB_JOINBUFSIZE) {
|
|
|
425a81 |
- if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
+ if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
/* We have no choice but to commit suicide. */
|
|
|
425a81 |
abort();
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -698,7 +698,7 @@ void jpc_qmfb_join_col(jpc_fix_t *a, int
|
|
|
425a81 |
#if !defined(HAVE_VLA)
|
|
|
425a81 |
/* Allocate memory for the join buffer from the heap. */
|
|
|
425a81 |
if (bufsize > QMFB_JOINBUFSIZE) {
|
|
|
425a81 |
- if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
+ if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
/* We have no choice but to commit suicide. */
|
|
|
425a81 |
abort();
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -766,7 +766,7 @@ void jpc_qmfb_join_colgrp(jpc_fix_t *a,
|
|
|
425a81 |
#if !defined(HAVE_VLA)
|
|
|
425a81 |
/* Allocate memory for the join buffer from the heap. */
|
|
|
425a81 |
if (bufsize > QMFB_JOINBUFSIZE) {
|
|
|
425a81 |
- if (!(buf = jas_malloc(bufsize * JPC_QMFB_COLGRPSIZE * sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
+ if (!(buf = jas_alloc2(bufsize, JPC_QMFB_COLGRPSIZE * sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
/* We have no choice but to commit suicide. */
|
|
|
425a81 |
abort();
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -852,7 +852,7 @@ void jpc_qmfb_join_colres(jpc_fix_t *a,
|
|
|
425a81 |
#if !defined(HAVE_VLA)
|
|
|
425a81 |
/* Allocate memory for the join buffer from the heap. */
|
|
|
425a81 |
if (bufsize > QMFB_JOINBUFSIZE) {
|
|
|
425a81 |
- if (!(buf = jas_malloc(bufsize * numcols * sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
+ if (!(buf = jas_alloc3(bufsize, numcols, sizeof(jpc_fix_t)))) {
|
|
|
425a81 |
/* We have no choice but to commit suicide. */
|
|
|
425a81 |
abort();
|
|
|
425a81 |
}
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/jpc/jpc_t1enc.c jasper-1.900.1/src/libjasper/jpc/jpc_t1enc.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/jpc/jpc_t1enc.c 2007-01-19 22:43:07.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/jpc/jpc_t1enc.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -219,7 +219,7 @@ int jpc_enc_enccblk(jpc_enc_t *enc, jas_
|
|
|
425a81 |
|
|
|
425a81 |
cblk->numpasses = (cblk->numbps > 0) ? (3 * cblk->numbps - 2) : 0;
|
|
|
425a81 |
if (cblk->numpasses > 0) {
|
|
|
425a81 |
- cblk->passes = jas_malloc(cblk->numpasses * sizeof(jpc_enc_pass_t));
|
|
|
425a81 |
+ cblk->passes = jas_alloc2(cblk->numpasses, sizeof(jpc_enc_pass_t));
|
|
|
425a81 |
assert(cblk->passes);
|
|
|
425a81 |
} else {
|
|
|
425a81 |
cblk->passes = 0;
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/jpc/jpc_t2cod.c jasper-1.900.1/src/libjasper/jpc/jpc_t2cod.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/jpc/jpc_t2cod.c 2007-01-19 22:43:07.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/jpc/jpc_t2cod.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -573,7 +573,7 @@ int jpc_pchglist_insert(jpc_pchglist_t *
|
|
|
425a81 |
}
|
|
|
425a81 |
if (pchglist->numpchgs >= pchglist->maxpchgs) {
|
|
|
425a81 |
newmaxpchgs = pchglist->maxpchgs + 128;
|
|
|
425a81 |
- if (!(newpchgs = jas_realloc(pchglist->pchgs, newmaxpchgs * sizeof(jpc_pchg_t *)))) {
|
|
|
425a81 |
+ if (!(newpchgs = jas_realloc2(pchglist->pchgs, newmaxpchgs, sizeof(jpc_pchg_t *)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
pchglist->maxpchgs = newmaxpchgs;
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/jpc/jpc_t2dec.c jasper-1.900.1/src/libjasper/jpc/jpc_t2dec.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/jpc/jpc_t2dec.c 2007-01-19 22:43:07.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/jpc/jpc_t2dec.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -478,7 +478,7 @@ jpc_pi_t *jpc_dec_pi_create(jpc_dec_t *d
|
|
|
425a81 |
return 0;
|
|
|
425a81 |
}
|
|
|
425a81 |
pi->numcomps = dec->numcomps;
|
|
|
425a81 |
- if (!(pi->picomps = jas_malloc(pi->numcomps * sizeof(jpc_picomp_t)))) {
|
|
|
425a81 |
+ if (!(pi->picomps = jas_alloc2(pi->numcomps, sizeof(jpc_picomp_t)))) {
|
|
|
425a81 |
jpc_pi_destroy(pi);
|
|
|
425a81 |
return 0;
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -490,7 +490,7 @@ jpc_pi_t *jpc_dec_pi_create(jpc_dec_t *d
|
|
|
425a81 |
for (compno = 0, tcomp = tile->tcomps, picomp = pi->picomps;
|
|
|
425a81 |
compno < pi->numcomps; ++compno, ++tcomp, ++picomp) {
|
|
|
425a81 |
picomp->numrlvls = tcomp->numrlvls;
|
|
|
425a81 |
- if (!(picomp->pirlvls = jas_malloc(picomp->numrlvls *
|
|
|
425a81 |
+ if (!(picomp->pirlvls = jas_alloc2(picomp->numrlvls,
|
|
|
425a81 |
sizeof(jpc_pirlvl_t)))) {
|
|
|
425a81 |
jpc_pi_destroy(pi);
|
|
|
425a81 |
return 0;
|
|
|
425a81 |
@@ -503,7 +503,7 @@ jpc_pi_t *jpc_dec_pi_create(jpc_dec_t *d
|
|
|
425a81 |
rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) {
|
|
|
425a81 |
/* XXX sizeof(long) should be sizeof different type */
|
|
|
425a81 |
pirlvl->numprcs = rlvl->numprcs;
|
|
|
425a81 |
- if (!(pirlvl->prclyrnos = jas_malloc(pirlvl->numprcs *
|
|
|
425a81 |
+ if (!(pirlvl->prclyrnos = jas_alloc2(pirlvl->numprcs,
|
|
|
425a81 |
sizeof(long)))) {
|
|
|
425a81 |
jpc_pi_destroy(pi);
|
|
|
425a81 |
return 0;
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/jpc/jpc_t2enc.c jasper-1.900.1/src/libjasper/jpc/jpc_t2enc.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/jpc/jpc_t2enc.c 2007-01-19 22:43:07.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/jpc/jpc_t2enc.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -565,7 +565,7 @@ jpc_pi_t *jpc_enc_pi_create(jpc_enc_cp_t
|
|
|
425a81 |
}
|
|
|
425a81 |
pi->pktno = -1;
|
|
|
425a81 |
pi->numcomps = cp->numcmpts;
|
|
|
425a81 |
- if (!(pi->picomps = jas_malloc(pi->numcomps * sizeof(jpc_picomp_t)))) {
|
|
|
425a81 |
+ if (!(pi->picomps = jas_alloc2(pi->numcomps, sizeof(jpc_picomp_t)))) {
|
|
|
425a81 |
jpc_pi_destroy(pi);
|
|
|
425a81 |
return 0;
|
|
|
425a81 |
}
|
|
|
425a81 |
@@ -577,7 +577,7 @@ jpc_pi_t *jpc_enc_pi_create(jpc_enc_cp_t
|
|
|
425a81 |
for (compno = 0, tcomp = tile->tcmpts, picomp = pi->picomps;
|
|
|
425a81 |
compno < pi->numcomps; ++compno, ++tcomp, ++picomp) {
|
|
|
425a81 |
picomp->numrlvls = tcomp->numrlvls;
|
|
|
425a81 |
- if (!(picomp->pirlvls = jas_malloc(picomp->numrlvls *
|
|
|
425a81 |
+ if (!(picomp->pirlvls = jas_alloc2(picomp->numrlvls,
|
|
|
425a81 |
sizeof(jpc_pirlvl_t)))) {
|
|
|
425a81 |
jpc_pi_destroy(pi);
|
|
|
425a81 |
return 0;
|
|
|
425a81 |
@@ -591,7 +591,7 @@ jpc_pi_t *jpc_enc_pi_create(jpc_enc_cp_t
|
|
|
425a81 |
/* XXX sizeof(long) should be sizeof different type */
|
|
|
425a81 |
pirlvl->numprcs = rlvl->numprcs;
|
|
|
425a81 |
if (rlvl->numprcs) {
|
|
|
425a81 |
- if (!(pirlvl->prclyrnos = jas_malloc(pirlvl->numprcs *
|
|
|
425a81 |
+ if (!(pirlvl->prclyrnos = jas_alloc2(pirlvl->numprcs,
|
|
|
425a81 |
sizeof(long)))) {
|
|
|
425a81 |
jpc_pi_destroy(pi);
|
|
|
425a81 |
return 0;
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/jpc/jpc_tagtree.c jasper-1.900.1/src/libjasper/jpc/jpc_tagtree.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/jpc/jpc_tagtree.c 2007-01-19 22:43:07.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/jpc/jpc_tagtree.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -125,7 +125,7 @@ jpc_tagtree_t *jpc_tagtree_create(int nu
|
|
|
425a81 |
++numlvls;
|
|
|
425a81 |
} while (n > 1);
|
|
|
425a81 |
|
|
|
425a81 |
- if (!(tree->nodes_ = jas_malloc(tree->numnodes_ * sizeof(jpc_tagtreenode_t)))) {
|
|
|
425a81 |
+ if (!(tree->nodes_ = jas_alloc2(tree->numnodes_, sizeof(jpc_tagtreenode_t)))) {
|
|
|
425a81 |
return 0;
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/jpc/jpc_util.c jasper-1.900.1/src/libjasper/jpc/jpc_util.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/jpc/jpc_util.c 2007-01-19 22:43:07.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/jpc/jpc_util.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -109,7 +109,7 @@ int jpc_atoaf(char *s, int *numvalues, d
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
if (n) {
|
|
|
425a81 |
- if (!(vs = jas_malloc(n * sizeof(double)))) {
|
|
|
425a81 |
+ if (!(vs = jas_alloc2(n, sizeof(double)))) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|
|
|
425a81 |
|
|
|
425a81 |
diff -pruN jasper-1.900.1.orig/src/libjasper/mif/mif_cod.c jasper-1.900.1/src/libjasper/mif/mif_cod.c
|
|
|
425a81 |
--- jasper-1.900.1.orig/src/libjasper/mif/mif_cod.c 2007-01-19 22:43:05.000000000 +0100
|
|
|
425a81 |
+++ jasper-1.900.1/src/libjasper/mif/mif_cod.c 2009-10-22 10:27:45.000000000 +0200
|
|
|
425a81 |
@@ -438,8 +438,7 @@ static int mif_hdr_growcmpts(mif_hdr_t *
|
|
|
425a81 |
int cmptno;
|
|
|
425a81 |
mif_cmpt_t **newcmpts;
|
|
|
425a81 |
assert(maxcmpts >= hdr->numcmpts);
|
|
|
425a81 |
- newcmpts = (!hdr->cmpts) ? jas_malloc(maxcmpts * sizeof(mif_cmpt_t *)) :
|
|
|
425a81 |
- jas_realloc(hdr->cmpts, maxcmpts * sizeof(mif_cmpt_t *));
|
|
|
425a81 |
+ newcmpts = jas_realloc2(hdr->cmpts, maxcmpts, sizeof(mif_cmpt_t *));
|
|
|
425a81 |
if (!newcmpts) {
|
|
|
425a81 |
return -1;
|
|
|
425a81 |
}
|