View | Details | Raw Unified | Return to bug 163718 | Differences between
and this patch

Collapse All | Expand All

(-)Makefile (-3 / +3 lines)
Lines 7-13 Link Here
7
7
8
PORTNAME=	jasper
8
PORTNAME=	jasper
9
PORTVERSION=	1.900.1
9
PORTVERSION=	1.900.1
10
PORTREVISION=	10
10
PORTREVISION=	11
11
CATEGORIES=	graphics
11
CATEGORIES=	graphics
12
MASTER_SITES=	http://www.ece.uvic.ca/~mdadams/jasper/software/ \
12
MASTER_SITES=	http://www.ece.uvic.ca/~mdadams/jasper/software/ \
13
		${MASTER_SITE_IMAGEMAGICK}
13
		${MASTER_SITE_IMAGEMAGICK}
Lines 16-25 Link Here
16
MAINTAINER=	dinoex@FreeBSD.org
16
MAINTAINER=	dinoex@FreeBSD.org
17
COMMENT=	An implementation of the codec specified in the JPEG-2000 standard
17
COMMENT=	An implementation of the codec specified in the JPEG-2000 standard
18
18
19
LIB_DEPENDS=	jpeg:${PORTSDIR}/graphics/jpeg
20
21
LICENSE=	MIT
19
LICENSE=	MIT
22
20
21
LIB_DEPENDS=	jpeg:${PORTSDIR}/graphics/jpeg
22
23
USE_AUTOTOOLS=	libtool
23
USE_AUTOTOOLS=	libtool
24
USE_ZIP=	yes
24
USE_ZIP=	yes
25
USE_GNOME=	lthack
25
USE_GNOME=	lthack
(-)files/patch-jas_stream.c (-19 lines)
Removed Link Here
1
--- src/libjasper/base/jas_stream.c	Fri Jan 19 16:43:05 2007
2
+++ src/libjasper/base/jas_stream.c	Tue Jun 12 10:26:02 2007
3
@@ -362,13 +362,12 @@
4
 	obj->fd = -1;
5
 	obj->flags = 0;
6
-	obj->pathname[0] = '\0';
7
+	snprintf(obj->pathname, sizeof(obj->pathname), "/tmp/jasper.XXXXXX");
8
 	stream->obj_ = obj;
9
 
10
 	/* Choose a file name. */
11
-	tmpnam(obj->pathname);
12
+	obj->fd = mkstemp(obj->pathname);
13
 
14
 	/* Open the underlying file. */
15
-	if ((obj->fd = open(obj->pathname, O_CREAT | O_EXCL | O_RDWR | O_TRUNC | O_BINARY,
16
-	  JAS_STREAM_PERMS)) < 0) {
17
+	if (obj->fd < 0) {
18
 		jas_stream_destroy(stream);
19
 		return 0;
(-)files/patch-jpc_cs.c (-11 lines)
Removed Link Here
1
--- src/libjasper/jpc/jpc_cs.c.orig	Fri Jan 19 21:43:07 2007
2
+++ src/libjasper/jpc/jpc_cs.c	Wed Feb  7 11:05:57 2007
3
@@ -288,7 +288,7 @@
4
 			jpc_ms_dump(ms, stderr);
5
 		}
6
 
7
-		if (JAS_CAST(ulong, jas_stream_tell(tmpstream)) != ms->len) {
8
+		if (JAS_CAST(unsigned long, jas_stream_tell(tmpstream)) != ms->len) {
9
 			jas_eprintf("warning: trailing garbage in marker segment (%ld bytes)\n",
10
 			  ms->len - jas_stream_tell(tmpstream));
11
 		}
(-)files/patch-jpc_dec.c (-17 lines)
Removed Link Here
1
--- src/libjasper/jpc/jpc_dec.c	2007-01-19 22:43:07.000000000 +0100
2
+++ src/libjasper/jpc/jpc_dec.c	2011-11-09 15:04:49.000000000 +0100
3
@@ -1069,12 +1069,12 @@
4
 	/* Apply an inverse intercomponent transform if necessary. */
5
 	switch (tile->cp->mctid) {
6
 	case JPC_MCT_RCT:
7
-		assert(dec->numcomps == 3);
8
+		assert(dec->numcomps == 3 || dec->numcomps == 4);
9
 		jpc_irct(tile->tcomps[0].data, tile->tcomps[1].data,
10
 		  tile->tcomps[2].data);
11
 		break;
12
 	case JPC_MCT_ICT:
13
-		assert(dec->numcomps == 3);
14
+		assert(dec->numcomps == 3 || dec->numcomps == 4);
15
 		jpc_iict(tile->tcomps[0].data, tile->tcomps[1].data,
16
 		  tile->tcomps[2].data);
17
 		break;
(-)files/patch-src__libjasper__base__jas_cm.c (+46 lines)
Added Link Here
1
--- ./src/libjasper/base/jas_cm.c.orig	2007-01-19 21:43:05.000000000 +0000
2
+++ ./src/libjasper/base/jas_cm.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -704,8 +704,7 @@
4
 {
5
 	jas_cmpxform_t **p;
6
 	assert(n >= pxformseq->numpxforms);
7
-	p = (!pxformseq->pxforms) ? jas_malloc(n * sizeof(jas_cmpxform_t *)) :
8
-	  jas_realloc(pxformseq->pxforms, n * sizeof(jas_cmpxform_t *));
9
+	p = jas_realloc2(pxformseq->pxforms, n, sizeof(jas_cmpxform_t *));
10
 	if (!p) {
11
 		return -1;
12
 	}
13
@@ -889,13 +888,13 @@
14
 	jas_cmshapmatlut_cleanup(lut);
15
 	if (curv->numents == 0) {
16
 		lut->size = 2;
17
-		if (!(lut->data = jas_malloc(lut->size * sizeof(jas_cmreal_t))))
18
+		if (!(lut->data = jas_alloc2(lut->size, sizeof(jas_cmreal_t))))
19
 			goto error;
20
 		lut->data[0] = 0.0;
21
 		lut->data[1] = 1.0;
22
 	} else if (curv->numents == 1) {
23
 		lut->size = 256;
24
-		if (!(lut->data = jas_malloc(lut->size * sizeof(jas_cmreal_t))))
25
+		if (!(lut->data = jas_alloc2(lut->size, sizeof(jas_cmreal_t))))
26
 			goto error;
27
 		gamma = curv->ents[0] / 256.0;
28
 		for (i = 0; i < lut->size; ++i) {
29
@@ -903,7 +902,7 @@
30
 		}
31
 	} else {
32
 		lut->size = curv->numents;
33
-		if (!(lut->data = jas_malloc(lut->size * sizeof(jas_cmreal_t))))
34
+		if (!(lut->data = jas_alloc2(lut->size, sizeof(jas_cmreal_t))))
35
 			goto error;
36
 		for (i = 0; i < lut->size; ++i) {
37
 			lut->data[i] = curv->ents[i] / 65535.0;
38
@@ -953,7 +952,7 @@
39
 			return -1;
40
 		}
41
 	}
42
-	if (!(invlut->data = jas_malloc(n * sizeof(jas_cmreal_t))))
43
+	if (!(invlut->data = jas_alloc2(n, sizeof(jas_cmreal_t))))
44
 		return -1;
45
 	invlut->size = n;
46
 	for (i = 0; i < invlut->size; ++i) {
(-)files/patch-src__libjasper__base__jas_icc.c (+98 lines)
Added Link Here
1
--- ./src/libjasper/base/jas_icc.c.orig	2007-01-19 21:43:05.000000000 +0000
2
+++ ./src/libjasper/base/jas_icc.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -373,7 +373,7 @@
4
 	jas_icctagtab_t *tagtab;
5
 
6
 	tagtab = &prof->tagtab;
7
-	if (!(tagtab->ents = jas_malloc(prof->attrtab->numattrs *
8
+	if (!(tagtab->ents = jas_alloc2(prof->attrtab->numattrs,
9
 	  sizeof(jas_icctagtabent_t))))
10
 		goto error;
11
 	tagtab->numents = prof->attrtab->numattrs;
12
@@ -522,7 +522,7 @@
13
 	}
14
 	if (jas_iccgetuint32(in, &tagtab->numents))
15
 		goto error;
16
-	if (!(tagtab->ents = jas_malloc(tagtab->numents *
17
+	if (!(tagtab->ents = jas_alloc2(tagtab->numents,
18
 	  sizeof(jas_icctagtabent_t))))
19
 		goto error;
20
 	tagtabent = tagtab->ents;
21
@@ -743,8 +743,7 @@
22
 {
23
 	jas_iccattr_t *newattrs;
24
 	assert(maxents >= tab->numattrs);
25
-	newattrs = tab->attrs ? jas_realloc(tab->attrs, maxents *
26
-	  sizeof(jas_iccattr_t)) : jas_malloc(maxents * sizeof(jas_iccattr_t));
27
+	newattrs = jas_realloc2(tab->attrs, maxents, sizeof(jas_iccattr_t));
28
 	if (!newattrs)
29
 		return -1;
30
 	tab->attrs = newattrs;
31
@@ -999,7 +998,7 @@
32
 
33
 	if (jas_iccgetuint32(in, &curv->numents))
34
 		goto error;
35
-	if (!(curv->ents = jas_malloc(curv->numents * sizeof(jas_iccuint16_t))))
36
+	if (!(curv->ents = jas_alloc2(curv->numents, sizeof(jas_iccuint16_t))))
37
 		goto error;
38
 	for (i = 0; i < curv->numents; ++i) {
39
 		if (jas_iccgetuint16(in, &curv->ents[i]))
40
@@ -1100,7 +1099,7 @@
41
 	if (jas_iccgetuint32(in, &txtdesc->uclangcode) ||
42
 	  jas_iccgetuint32(in, &txtdesc->uclen))
43
 		goto error;
44
-	if (!(txtdesc->ucdata = jas_malloc(txtdesc->uclen * 2)))
45
+	if (!(txtdesc->ucdata = jas_alloc2(txtdesc->uclen, 2)))
46
 		goto error;
47
 	if (jas_stream_read(in, txtdesc->ucdata, txtdesc->uclen * 2) !=
48
 	  JAS_CAST(int, txtdesc->uclen * 2))
49
@@ -1292,17 +1291,17 @@
50
 	  jas_iccgetuint16(in, &lut8->numouttabents))
51
 		goto error;
52
 	clutsize = jas_iccpowi(lut8->clutlen, lut8->numinchans) * lut8->numoutchans;
53
-	if (!(lut8->clut = jas_malloc(clutsize * sizeof(jas_iccuint8_t))) ||
54
-	  !(lut8->intabsbuf = jas_malloc(lut8->numinchans *
55
-	  lut8->numintabents * sizeof(jas_iccuint8_t))) ||
56
-	  !(lut8->intabs = jas_malloc(lut8->numinchans *
57
+	if (!(lut8->clut = jas_alloc2(clutsize, sizeof(jas_iccuint8_t))) ||
58
+	  !(lut8->intabsbuf = jas_alloc3(lut8->numinchans,
59
+	  lut8->numintabents, sizeof(jas_iccuint8_t))) ||
60
+	  !(lut8->intabs = jas_alloc2(lut8->numinchans,
61
 	  sizeof(jas_iccuint8_t *))))
62
 		goto error;
63
 	for (i = 0; i < lut8->numinchans; ++i)
64
 		lut8->intabs[i] = &lut8->intabsbuf[i * lut8->numintabents];
65
-	if (!(lut8->outtabsbuf = jas_malloc(lut8->numoutchans *
66
-	  lut8->numouttabents * sizeof(jas_iccuint8_t))) ||
67
-	  !(lut8->outtabs = jas_malloc(lut8->numoutchans *
68
+	if (!(lut8->outtabsbuf = jas_alloc3(lut8->numoutchans,
69
+	  lut8->numouttabents, sizeof(jas_iccuint8_t))) ||
70
+	  !(lut8->outtabs = jas_alloc2(lut8->numoutchans,
71
 	  sizeof(jas_iccuint8_t *))))
72
 		goto error;
73
 	for (i = 0; i < lut8->numoutchans; ++i)
74
@@ -1461,17 +1460,17 @@
75
 	  jas_iccgetuint16(in, &lut16->numouttabents))
76
 		goto error;
77
 	clutsize = jas_iccpowi(lut16->clutlen, lut16->numinchans) * lut16->numoutchans;
78
-	if (!(lut16->clut = jas_malloc(clutsize * sizeof(jas_iccuint16_t))) ||
79
-	  !(lut16->intabsbuf = jas_malloc(lut16->numinchans *
80
-	  lut16->numintabents * sizeof(jas_iccuint16_t))) ||
81
-	  !(lut16->intabs = jas_malloc(lut16->numinchans *
82
+	if (!(lut16->clut = jas_alloc2(clutsize, sizeof(jas_iccuint16_t))) ||
83
+	  !(lut16->intabsbuf = jas_alloc3(lut16->numinchans,
84
+	  lut16->numintabents, sizeof(jas_iccuint16_t))) ||
85
+	  !(lut16->intabs = jas_alloc2(lut16->numinchans,
86
 	  sizeof(jas_iccuint16_t *))))
87
 		goto error;
88
 	for (i = 0; i < lut16->numinchans; ++i)
89
 		lut16->intabs[i] = &lut16->intabsbuf[i * lut16->numintabents];
90
-	if (!(lut16->outtabsbuf = jas_malloc(lut16->numoutchans *
91
-	  lut16->numouttabents * sizeof(jas_iccuint16_t))) ||
92
-	  !(lut16->outtabs = jas_malloc(lut16->numoutchans *
93
+	if (!(lut16->outtabsbuf = jas_alloc3(lut16->numoutchans,
94
+	  lut16->numouttabents, sizeof(jas_iccuint16_t))) ||
95
+	  !(lut16->outtabs = jas_alloc2(lut16->numoutchans,
96
 	  sizeof(jas_iccuint16_t *))))
97
 		goto error;
98
 	for (i = 0; i < lut16->numoutchans; ++i)
(-)files/patch-src__libjasper__base__jas_image.c (+21 lines)
Added Link Here
1
--- ./src/libjasper/base/jas_image.c.orig	2007-01-19 21:43:05.000000000 +0000
2
+++ ./src/libjasper/base/jas_image.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -142,7 +142,7 @@
4
 	image->inmem_ = true;
5
 
6
 	/* Allocate memory for the per-component information. */
7
-	if (!(image->cmpts_ = jas_malloc(image->maxcmpts_ *
8
+	if (!(image->cmpts_ = jas_alloc2(image->maxcmpts_,
9
 	  sizeof(jas_image_cmpt_t *)))) {
10
 		jas_image_destroy(image);
11
 		return 0;
12
@@ -774,8 +774,7 @@
13
 	jas_image_cmpt_t **newcmpts;
14
 	int cmptno;
15
 
16
-	newcmpts = (!image->cmpts_) ? jas_malloc(maxcmpts * sizeof(jas_image_cmpt_t *)) :
17
-	  jas_realloc(image->cmpts_, maxcmpts * sizeof(jas_image_cmpt_t *));
18
+	newcmpts = jas_realloc2(image->cmpts_, maxcmpts, sizeof(jas_image_cmpt_t *));
19
 	if (!newcmpts) {
20
 		return -1;
21
 	}
(-)files/patch-src__libjasper__base__jas_malloc.c (+70 lines)
Added Link Here
1
--- ./src/libjasper/base/jas_malloc.c.orig	2007-01-19 21:43:05.000000000 +0000
2
+++ ./src/libjasper/base/jas_malloc.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -76,6 +76,9 @@
4
 
5
 /* We need the prototype for memset. */
6
 #include <string.h>
7
+#include <limits.h>
8
+#include <errno.h>
9
+#include <stdint.h>
10
 
11
 #include "jasper/jas_malloc.h"
12
 
13
@@ -113,18 +116,50 @@
14
 
15
 void *jas_realloc(void *ptr, size_t size)
16
 {
17
-	return realloc(ptr, size);
18
+	return ptr ? realloc(ptr, size) : malloc(size);
19
 }
20
 
21
-void *jas_calloc(size_t nmemb, size_t size)
22
+void *jas_realloc2(void *ptr, size_t nmemb, size_t size)
23
+{
24
+	if (!ptr)
25
+		return jas_alloc2(nmemb, size);
26
+	if (nmemb && SIZE_MAX / nmemb < size) {
27
+		errno = ENOMEM;
28
+		return NULL;
29
+	}
30
+	return jas_realloc(ptr, nmemb * size);
31
+
32
+}
33
+
34
+void *jas_alloc2(size_t nmemb, size_t size)
35
+{
36
+	if (nmemb && SIZE_MAX / nmemb < size) {
37
+		errno = ENOMEM;
38
+		return NULL;
39
+	}
40
+
41
+	return jas_malloc(nmemb * size);
42
+}
43
+
44
+void *jas_alloc3(size_t a, size_t b, size_t c)
45
 {
46
-	void *ptr;
47
 	size_t n;
48
-	n = nmemb * size;
49
-	if (!(ptr = jas_malloc(n * sizeof(char)))) {
50
-		return 0;
51
+
52
+	if (a && SIZE_MAX / a < b) {
53
+		errno = ENOMEM;
54
+		return NULL;
55
 	}
56
-	memset(ptr, 0, n);
57
+
58
+	return jas_alloc2(a*b, c);
59
+}
60
+
61
+void *jas_calloc(size_t nmemb, size_t size)
62
+{
63
+	void *ptr;
64
+
65
+	ptr = jas_alloc2(nmemb, size);
66
+	if (ptr)
67
+		memset(ptr, 0, nmemb*size);
68
 	return ptr;
69
 }
70
 
(-)files/patch-src__libjasper__base__jas_seq.c (+29 lines)
Added Link Here
1
--- ./src/libjasper/base/jas_seq.c.orig	2007-01-19 21:43:05.000000000 +0000
2
+++ ./src/libjasper/base/jas_seq.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -114,7 +114,7 @@
4
 	matrix->datasize_ = numrows * numcols;
5
 
6
 	if (matrix->maxrows_ > 0) {
7
-		if (!(matrix->rows_ = jas_malloc(matrix->maxrows_ *
8
+		if (!(matrix->rows_ = jas_alloc2(matrix->maxrows_,
9
 		  sizeof(jas_seqent_t *)))) {
10
 			jas_matrix_destroy(matrix);
11
 			return 0;
12
@@ -122,7 +122,7 @@
13
 	}
14
 
15
 	if (matrix->datasize_ > 0) {
16
-		if (!(matrix->data_ = jas_malloc(matrix->datasize_ *
17
+		if (!(matrix->data_ = jas_alloc2(matrix->datasize_,
18
 		  sizeof(jas_seqent_t)))) {
19
 			jas_matrix_destroy(matrix);
20
 			return 0;
21
@@ -220,7 +220,7 @@
22
 	mat0->numrows_ = r1 - r0 + 1;
23
 	mat0->numcols_ = c1 - c0 + 1;
24
 	mat0->maxrows_ = mat0->numrows_;
25
-	mat0->rows_ = jas_malloc(mat0->maxrows_ * sizeof(jas_seqent_t *));
26
+	mat0->rows_ = jas_alloc2(mat0->maxrows_, sizeof(jas_seqent_t *));
27
 	for (i = 0; i < mat0->numrows_; ++i) {
28
 		mat0->rows_[i] = mat1->rows_[r0 + i] + c0;
29
 	}
(-)files/patch-src__libjasper__base__jas_stream.c (+48 lines)
Added Link Here
1
--- ./src/libjasper/base/jas_stream.c.orig	2011-12-30 03:00:54.000000000 +0000
2
+++ ./src/libjasper/base/jas_stream.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -212,7 +212,7 @@
4
 	if (buf) {
5
 		obj->buf_ = (unsigned char *) buf;
6
 	} else {
7
-		obj->buf_ = jas_malloc(obj->bufsize_ * sizeof(char));
8
+		obj->buf_ = jas_malloc(obj->bufsize_);
9
 		obj->myalloc_ = 1;
10
 	}
11
 	if (!obj->buf_) {
12
@@ -361,15 +361,14 @@
13
 	}
14
 	obj->fd = -1;
15
 	obj->flags = 0;
16
-	obj->pathname[0] = '\0';
17
+	snprintf(obj->pathname, sizeof(obj->pathname), "/tmp/jasper.XXXXXX");
18
 	stream->obj_ = obj;
19
 
20
 	/* Choose a file name. */
21
-	tmpnam(obj->pathname);
22
+	obj->fd = mkstemp(obj->pathname);
23
 
24
 	/* Open the underlying file. */
25
-	if ((obj->fd = open(obj->pathname, O_CREAT | O_EXCL | O_RDWR | O_TRUNC | O_BINARY,
26
-	  JAS_STREAM_PERMS)) < 0) {
27
+	if (obj->fd < 0) {
28
 		jas_stream_destroy(stream);
29
 		return 0;
30
 	}
31
@@ -553,7 +552,7 @@
32
 	int ret;
33
 
34
 	va_start(ap, fmt);
35
-	ret = vsprintf(buf, fmt, ap);
36
+	ret = vsnprintf(buf, sizeof buf, fmt, ap);
37
 	jas_stream_puts(stream, buf);
38
 	va_end(ap);
39
 	return ret;
40
@@ -992,7 +991,7 @@
41
 	unsigned char *buf;
42
 
43
 	assert(m->buf_);
44
-	if (!(buf = jas_realloc(m->buf_, bufsize * sizeof(unsigned char)))) {
45
+	if (!(buf = jas_realloc(m->buf_, bufsize))) {
46
 		return -1;
47
 	}
48
 	m->buf_ = buf;
(-)files/patch-src__libjasper__bmp__bmp_dec.c (+11 lines)
Added Link Here
1
--- ./src/libjasper/bmp/bmp_dec.c.orig	2007-01-19 21:43:07.000000000 +0000
2
+++ ./src/libjasper/bmp/bmp_dec.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -283,7 +283,7 @@
4
 	}
5
 
6
 	if (info->numcolors > 0) {
7
-		if (!(info->palents = jas_malloc(info->numcolors *
8
+		if (!(info->palents = jas_alloc2(info->numcolors,
9
 		  sizeof(bmp_palent_t)))) {
10
 			bmp_info_destroy(info);
11
 			return 0;
(-)files/patch-src__libjasper__include__jasper__jas_malloc.h (+25 lines)
Added Link Here
1
--- ./src/libjasper/include/jasper/jas_malloc.h.orig	2007-01-19 21:43:04.000000000 +0000
2
+++ ./src/libjasper/include/jasper/jas_malloc.h	2011-12-30 03:00:54.000000000 +0000
3
@@ -95,6 +95,9 @@
4
 #define	jas_free	MEMFREE
5
 #define	jas_realloc	MEMREALLOC
6
 #define	jas_calloc	MEMCALLOC
7
+#define jas_alloc2(a, b)	MEMALLOC((a)*(b))
8
+#define jas_alloc3(a, b, c)	MEMALLOC((a)*(b)*(c))
9
+#define jas_realloc2(p, a, b)	MEMREALLOC((p), (a)*(b))
10
 #endif
11
 
12
 /******************************************************************************\
13
@@ -115,6 +118,12 @@
14
 /* Allocate a block of memory and initialize the contents to zero. */
15
 void *jas_calloc(size_t nmemb, size_t size);
16
 
17
+/* size-checked double allocation .*/
18
+void *jas_alloc2(size_t, size_t);
19
+
20
+void *jas_alloc3(size_t, size_t, size_t);
21
+
22
+void *jas_realloc2(void *, size_t, size_t);
23
 #endif
24
 
25
 #ifdef __cplusplus
(-)files/patch-src__libjasper__jp2__jp2_cod.c (+60 lines)
Added Link Here
1
--- ./src/libjasper/jp2/jp2_cod.c.orig	2007-01-19 21:43:05.000000000 +0000
2
+++ ./src/libjasper/jp2/jp2_cod.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -247,7 +247,7 @@
4
 	box = 0;
5
 	tmpstream = 0;
6
 
7
-	if (!(box = jas_malloc(sizeof(jp2_box_t)))) {
8
+	if (!(box = jas_calloc(1, sizeof(jp2_box_t)))) {
9
 		goto error;
10
 	}
11
 	box->ops = &jp2_boxinfo_unk.ops;
12
@@ -372,7 +372,7 @@
13
 	jp2_bpcc_t *bpcc = &box->data.bpcc;
14
 	unsigned int i;
15
 	bpcc->numcmpts = box->datalen;
16
-	if (!(bpcc->bpcs = jas_malloc(bpcc->numcmpts * sizeof(uint_fast8_t)))) {
17
+	if (!(bpcc->bpcs = jas_alloc2(bpcc->numcmpts, sizeof(uint_fast8_t)))) {
18
 		return -1;
19
 	}
20
 	for (i = 0; i < bpcc->numcmpts; ++i) {
21
@@ -416,7 +416,7 @@
22
 		break;
23
 	case JP2_COLR_ICC:
24
 		colr->iccplen = box->datalen - 3;
25
-		if (!(colr->iccp = jas_malloc(colr->iccplen * sizeof(uint_fast8_t)))) {
26
+		if (!(colr->iccp = jas_alloc2(colr->iccplen, sizeof(uint_fast8_t)))) {
27
 			return -1;
28
 		}
29
 		if (jas_stream_read(in, colr->iccp, colr->iccplen) != colr->iccplen) {
30
@@ -453,7 +453,7 @@
31
 	if (jp2_getuint16(in, &cdef->numchans)) {
32
 		return -1;
33
 	}
34
-	if (!(cdef->ents = jas_malloc(cdef->numchans * sizeof(jp2_cdefchan_t)))) {
35
+	if (!(cdef->ents = jas_alloc2(cdef->numchans, sizeof(jp2_cdefchan_t)))) {
36
 		return -1;
37
 	}
38
 	for (channo = 0; channo < cdef->numchans; ++channo) {
39
@@ -766,7 +766,7 @@
40
 	unsigned int i;
41
 
42
 	cmap->numchans = (box->datalen) / 4;
43
-	if (!(cmap->ents = jas_malloc(cmap->numchans * sizeof(jp2_cmapent_t)))) {
44
+	if (!(cmap->ents = jas_alloc2(cmap->numchans, sizeof(jp2_cmapent_t)))) {
45
 		return -1;
46
 	}
47
 	for (i = 0; i < cmap->numchans; ++i) {
48
@@ -828,10 +828,10 @@
49
 		return -1;
50
 	}
51
 	lutsize = pclr->numlutents * pclr->numchans;
52
-	if (!(pclr->lutdata = jas_malloc(lutsize * sizeof(int_fast32_t)))) {
53
+	if (!(pclr->lutdata = jas_alloc2(lutsize, sizeof(int_fast32_t)))) {
54
 		return -1;
55
 	}
56
-	if (!(pclr->bpc = jas_malloc(pclr->numchans * sizeof(uint_fast8_t)))) {
57
+	if (!(pclr->bpc = jas_alloc2(pclr->numchans, sizeof(uint_fast8_t)))) {
58
 		return -1;
59
 	}
60
 	for (i = 0; i < pclr->numchans; ++i) {
(-)files/patch-src__libjasper__jp2__jp2_dec.c (+20 lines)
Added Link Here
1
--- ./src/libjasper/jp2/jp2_dec.c.orig	2007-01-19 21:43:05.000000000 +0000
2
+++ ./src/libjasper/jp2/jp2_dec.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -336,7 +336,7 @@
4
 	}
5
 
6
 	/* Allocate space for the channel-number to component-number LUT. */
7
-	if (!(dec->chantocmptlut = jas_malloc(dec->numchans * sizeof(uint_fast16_t)))) {
8
+	if (!(dec->chantocmptlut = jas_alloc2(dec->numchans, sizeof(uint_fast16_t)))) {
9
 		jas_eprintf("error: no memory\n");
10
 		goto error;
11
 	}
12
@@ -354,7 +354,7 @@
13
 			if (cmapent->map == JP2_CMAP_DIRECT) {
14
 				dec->chantocmptlut[channo] = channo;
15
 			} else if (cmapent->map == JP2_CMAP_PALETTE) {
16
-				lutents = jas_malloc(pclrd->numlutents * sizeof(int_fast32_t));
17
+				lutents = jas_alloc2(pclrd->numlutents, sizeof(int_fast32_t));
18
 				for (i = 0; i < pclrd->numlutents; ++i) {
19
 					lutents[i] = pclrd->lutdata[cmapent->pcol + i * pclrd->numchans];
20
 				}
(-)files/patch-src__libjasper__jp2__jp2_enc.c (+20 lines)
Added Link Here
1
--- ./src/libjasper/jp2/jp2_enc.c.orig	2007-01-19 21:43:05.000000000 +0000
2
+++ ./src/libjasper/jp2/jp2_enc.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -191,7 +191,7 @@
4
 		}
5
 		bpcc = &box->data.bpcc;
6
 		bpcc->numcmpts = jas_image_numcmpts(image);
7
-		if (!(bpcc->bpcs = jas_malloc(bpcc->numcmpts *
8
+		if (!(bpcc->bpcs = jas_alloc2(bpcc->numcmpts,
9
 		  sizeof(uint_fast8_t)))) {
10
 			goto error;
11
 		}
12
@@ -285,7 +285,7 @@
13
 		}
14
 		cdef = &box->data.cdef;
15
 		cdef->numchans = jas_image_numcmpts(image);
16
-		cdef->ents = jas_malloc(cdef->numchans * sizeof(jp2_cdefchan_t));
17
+		cdef->ents = jas_alloc2(cdef->numchans, sizeof(jp2_cdefchan_t));
18
 		for (i = 0; i < jas_image_numcmpts(image); ++i) {
19
 			cdefchanent = &cdef->ents[i];
20
 			cdefchanent->channo = i;
(-)files/patch-src__libjasper__jpc__jpc_cs.c (+85 lines)
Added Link Here
1
--- ./src/libjasper/jpc/jpc_cs.c.orig	2011-12-30 03:00:54.000000000 +0000
2
+++ ./src/libjasper/jpc/jpc_cs.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -288,7 +288,7 @@
4
 			jpc_ms_dump(ms, stderr);
5
 		}
6
 
7
-		if (JAS_CAST(ulong, jas_stream_tell(tmpstream)) != ms->len) {
8
+		if (JAS_CAST(unsigned long, jas_stream_tell(tmpstream)) != ms->len) {
9
 			jas_eprintf("warning: trailing garbage in marker segment (%ld bytes)\n",
10
 			  ms->len - jas_stream_tell(tmpstream));
11
 		}
12
@@ -502,7 +502,7 @@
13
 	  !siz->tileheight || !siz->numcomps) {
14
 		return -1;
15
 	}
16
-	if (!(siz->comps = jas_malloc(siz->numcomps * sizeof(jpc_sizcomp_t)))) {
17
+	if (!(siz->comps = jas_alloc2(siz->numcomps, sizeof(jpc_sizcomp_t)))) {
18
 		return -1;
19
 	}
20
 	for (i = 0; i < siz->numcomps; ++i) {
21
@@ -744,6 +744,10 @@
22
 		return -1;
23
 	}
24
 	compparms->numrlvls = compparms->numdlvls + 1;
25
+	if (compparms->numrlvls > JPC_MAXRLVLS) {
26
+		jpc_cox_destroycompparms(compparms);
27
+		return -1;
28
+	}
29
 	if (prtflag) {
30
 		for (i = 0; i < compparms->numrlvls; ++i) {
31
 			if (jpc_getuint8(in, &tmp)) {
32
@@ -983,7 +987,7 @@
33
 		break;
34
 	}
35
 	if (compparms->numstepsizes > 0) {
36
-		compparms->stepsizes = jas_malloc(compparms->numstepsizes *
37
+		compparms->stepsizes = jas_alloc2(compparms->numstepsizes,
38
 		  sizeof(uint_fast16_t));
39
 		assert(compparms->stepsizes);
40
 		for (i = 0; i < compparms->numstepsizes; ++i) {
41
@@ -1091,7 +1095,7 @@
42
 
43
 	ppm->len = ms->len - 1;
44
 	if (ppm->len > 0) {
45
-		if (!(ppm->data = jas_malloc(ppm->len * sizeof(unsigned char)))) {
46
+		if (!(ppm->data = jas_malloc(ppm->len))) {
47
 			goto error;
48
 		}
49
 		if (JAS_CAST(uint, jas_stream_read(in, ppm->data, ppm->len)) != ppm->len) {
50
@@ -1160,7 +1164,7 @@
51
 	}
52
 	ppt->len = ms->len - 1;
53
 	if (ppt->len > 0) {
54
-		if (!(ppt->data = jas_malloc(ppt->len * sizeof(unsigned char)))) {
55
+		if (!(ppt->data = jas_malloc(ppt->len))) {
56
 			goto error;
57
 		}
58
 		if (jas_stream_read(in, (char *) ppt->data, ppt->len) != JAS_CAST(int, ppt->len)) {
59
@@ -1223,7 +1227,7 @@
60
 	uint_fast8_t tmp;
61
 	poc->numpchgs = (cstate->numcomps > 256) ? (ms->len / 9) :
62
 	  (ms->len / 7);
63
-	if (!(poc->pchgs = jas_malloc(poc->numpchgs * sizeof(jpc_pocpchg_t)))) {
64
+	if (!(poc->pchgs = jas_alloc2(poc->numpchgs, sizeof(jpc_pocpchg_t)))) {
65
 		goto error;
66
 	}
67
 	for (pchgno = 0, pchg = poc->pchgs; pchgno < poc->numpchgs; ++pchgno,
68
@@ -1328,7 +1332,7 @@
69
 	jpc_crgcomp_t *comp;
70
 	uint_fast16_t compno;
71
 	crg->numcomps = cstate->numcomps;
72
-	if (!(crg->comps = jas_malloc(cstate->numcomps * sizeof(uint_fast16_t)))) {
73
+	if (!(crg->comps = jas_alloc2(cstate->numcomps, sizeof(jpc_crgcomp_t)))) {
74
 		return -1;
75
 	}
76
 	for (compno = 0, comp = crg->comps; compno < cstate->numcomps;
77
@@ -1467,7 +1471,7 @@
78
 	cstate = 0;
79
 
80
 	if (ms->len > 0) {
81
-		if (!(unk->data = jas_malloc(ms->len * sizeof(unsigned char)))) {
82
+		if (!(unk->data = jas_malloc(ms->len))) {
83
 			return -1;
84
 		}
85
 		if (jas_stream_read(in, (char *) unk->data, ms->len) != JAS_CAST(int, ms->len)) {
(-)files/patch-src__libjasper__jpc__jpc_dec.c (+128 lines)
Added Link Here
1
--- ./src/libjasper/jpc/jpc_dec.c.orig	2011-12-30 03:00:54.000000000 +0000
2
+++ ./src/libjasper/jpc/jpc_dec.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -449,7 +449,7 @@
4
 
5
 	if (dec->state == JPC_MH) {
6
 
7
-		compinfos = jas_malloc(dec->numcomps * sizeof(jas_image_cmptparm_t));
8
+		compinfos = jas_alloc2(dec->numcomps, sizeof(jas_image_cmptparm_t));
9
 		assert(compinfos);
10
 		for (cmptno = 0, cmpt = dec->cmpts, compinfo = compinfos;
11
 		  cmptno < dec->numcomps; ++cmptno, ++cmpt, ++compinfo) {
12
@@ -692,7 +692,7 @@
13
 			tile->realmode = 1;
14
 		}
15
 		tcomp->numrlvls = ccp->numrlvls;
16
-		if (!(tcomp->rlvls = jas_malloc(tcomp->numrlvls *
17
+		if (!(tcomp->rlvls = jas_alloc2(tcomp->numrlvls,
18
 		  sizeof(jpc_dec_rlvl_t)))) {
19
 			return -1;
20
 		}
21
@@ -764,7 +764,7 @@
22
 			  rlvl->cbgheightexpn);
23
 
24
 			rlvl->numbands = (!rlvlno) ? 1 : 3;
25
-			if (!(rlvl->bands = jas_malloc(rlvl->numbands *
26
+			if (!(rlvl->bands = jas_alloc2(rlvl->numbands,
27
 			  sizeof(jpc_dec_band_t)))) {
28
 				return -1;
29
 			}
30
@@ -797,7 +797,7 @@
31
 
32
 				assert(rlvl->numprcs);
33
 
34
-				if (!(band->prcs = jas_malloc(rlvl->numprcs * sizeof(jpc_dec_prc_t)))) {
35
+				if (!(band->prcs = jas_alloc2(rlvl->numprcs, sizeof(jpc_dec_prc_t)))) {
36
 					return -1;
37
 				}
38
 
39
@@ -834,7 +834,7 @@
40
 			if (!(prc->numimsbstagtree = jpc_tagtree_create(prc->numhcblks, prc->numvcblks))) {
41
 				return -1;
42
 			}
43
-			if (!(prc->cblks = jas_malloc(prc->numcblks * sizeof(jpc_dec_cblk_t)))) {
44
+			if (!(prc->cblks = jas_alloc2(prc->numcblks, sizeof(jpc_dec_cblk_t)))) {
45
 				return -1;
46
 			}
47
 
48
@@ -1069,12 +1069,12 @@
49
 	/* Apply an inverse intercomponent transform if necessary. */
50
 	switch (tile->cp->mctid) {
51
 	case JPC_MCT_RCT:
52
-		assert(dec->numcomps == 3);
53
+		assert(dec->numcomps == 3 || dec->numcomps == 4);
54
 		jpc_irct(tile->tcomps[0].data, tile->tcomps[1].data,
55
 		  tile->tcomps[2].data);
56
 		break;
57
 	case JPC_MCT_ICT:
58
-		assert(dec->numcomps == 3);
59
+		assert(dec->numcomps == 3 || dec->numcomps == 4);
60
 		jpc_iict(tile->tcomps[0].data, tile->tcomps[1].data,
61
 		  tile->tcomps[2].data);
62
 		break;
63
@@ -1181,7 +1181,7 @@
64
 		return -1;
65
 	}
66
 
67
-	if (!(dec->cmpts = jas_malloc(dec->numcomps * sizeof(jpc_dec_cmpt_t)))) {
68
+	if (!(dec->cmpts = jas_alloc2(dec->numcomps, sizeof(jpc_dec_cmpt_t)))) {
69
 		return -1;
70
 	}
71
 
72
@@ -1204,7 +1204,7 @@
73
 	dec->numhtiles = JPC_CEILDIV(dec->xend - dec->tilexoff, dec->tilewidth);
74
 	dec->numvtiles = JPC_CEILDIV(dec->yend - dec->tileyoff, dec->tileheight);
75
 	dec->numtiles = dec->numhtiles * dec->numvtiles;
76
-	if (!(dec->tiles = jas_malloc(dec->numtiles * sizeof(jpc_dec_tile_t)))) {
77
+	if (!(dec->tiles = jas_calloc(dec->numtiles, sizeof(jpc_dec_tile_t)))) {
78
 		return -1;
79
 	}
80
 
81
@@ -1228,7 +1228,7 @@
82
 		tile->pkthdrstreampos = 0;
83
 		tile->pptstab = 0;
84
 		tile->cp = 0;
85
-		if (!(tile->tcomps = jas_malloc(dec->numcomps *
86
+		if (!(tile->tcomps = jas_calloc(dec->numcomps,
87
 		  sizeof(jpc_dec_tcomp_t)))) {
88
 			return -1;
89
 		}
90
@@ -1489,7 +1489,7 @@
91
 	cp->numlyrs = 0;
92
 	cp->mctid = 0;
93
 	cp->csty = 0;
94
-	if (!(cp->ccps = jas_malloc(cp->numcomps * sizeof(jpc_dec_ccp_t)))) {
95
+	if (!(cp->ccps = jas_alloc2(cp->numcomps, sizeof(jpc_dec_ccp_t)))) {
96
 		return 0;
97
 	}
98
 	if (!(cp->pchglist = jpc_pchglist_create())) {
99
@@ -2048,7 +2048,7 @@
100
 	}
101
 	streamlist->numstreams = 0;
102
 	streamlist->maxstreams = 100;
103
-	if (!(streamlist->streams = jas_malloc(streamlist->maxstreams *
104
+	if (!(streamlist->streams = jas_alloc2(streamlist->maxstreams,
105
 	  sizeof(jas_stream_t *)))) {
106
 		jas_free(streamlist);
107
 		return 0;
108
@@ -2068,8 +2068,8 @@
109
 	/* Grow the array of streams if necessary. */
110
 	if (streamlist->numstreams >= streamlist->maxstreams) {
111
 		newmaxstreams = streamlist->maxstreams + 1024;
112
-		if (!(newstreams = jas_realloc(streamlist->streams,
113
-		  (newmaxstreams + 1024) * sizeof(jas_stream_t *)))) {
114
+		if (!(newstreams = jas_realloc2(streamlist->streams,
115
+		  (newmaxstreams + 1024), sizeof(jas_stream_t *)))) {
116
 			return -1;
117
 		}
118
 		for (i = streamlist->numstreams; i < streamlist->maxstreams; ++i) {
119
@@ -2155,8 +2155,7 @@
120
 {
121
 	jpc_ppxstabent_t **newents;
122
 	if (tab->maxents < maxents) {
123
-		newents = (tab->ents) ? jas_realloc(tab->ents, maxents *
124
-		  sizeof(jpc_ppxstabent_t *)) : jas_malloc(maxents * sizeof(jpc_ppxstabent_t *));
125
+		newents = jas_realloc2(tab->ents, maxents, sizeof(jpc_ppxstabent_t *));
126
 		if (!newents) {
127
 			return -1;
128
 		}
(-)files/patch-src__libjasper__jpc__jpc_enc.c (+92 lines)
Added Link Here
1
--- ./src/libjasper/jpc/jpc_enc.c.orig	2007-01-19 21:43:07.000000000 +0000
2
+++ ./src/libjasper/jpc/jpc_enc.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -403,7 +403,7 @@
4
 		vsteplcm *= jas_image_cmptvstep(image, cmptno);
5
 	}
6
 
7
-	if (!(cp->ccps = jas_malloc(cp->numcmpts * sizeof(jpc_enc_ccp_t)))) {
8
+	if (!(cp->ccps = jas_alloc2(cp->numcmpts, sizeof(jpc_enc_ccp_t)))) {
9
 		goto error;
10
 	}
11
 	for (cmptno = 0, ccp = cp->ccps; cmptno < JAS_CAST(int, cp->numcmpts); ++cmptno,
12
@@ -656,7 +656,7 @@
13
 
14
 	if (ilyrrates && numilyrrates > 0) {
15
 		tcp->numlyrs = numilyrrates + 1;
16
-		if (!(tcp->ilyrrates = jas_malloc((tcp->numlyrs - 1) *
17
+		if (!(tcp->ilyrrates = jas_alloc2((tcp->numlyrs - 1),
18
 		  sizeof(jpc_fix_t)))) {
19
 			goto error;
20
 		}
21
@@ -940,7 +940,7 @@
22
 	siz->tilewidth = cp->tilewidth;
23
 	siz->tileheight = cp->tileheight;
24
 	siz->numcomps = cp->numcmpts;
25
-	siz->comps = jas_malloc(siz->numcomps * sizeof(jpc_sizcomp_t));
26
+	siz->comps = jas_alloc2(siz->numcomps, sizeof(jpc_sizcomp_t));
27
 	assert(siz->comps);
28
 	for (i = 0; i < JAS_CAST(int, cp->numcmpts); ++i) {
29
 		siz->comps[i].prec = cp->ccps[i].prec;
30
@@ -977,7 +977,7 @@
31
 		return -1;
32
 	}
33
 	crg = &enc->mrk->parms.crg;
34
-	crg->comps = jas_malloc(crg->numcomps * sizeof(jpc_crgcomp_t));
35
+	crg->comps = jas_alloc2(crg->numcomps, sizeof(jpc_crgcomp_t));
36
 	if (jpc_putms(enc->out, enc->cstate, enc->mrk)) {
37
 		jas_eprintf("cannot write CRG marker\n");
38
 		return -1;
39
@@ -1955,7 +1955,7 @@
40
 	tile->mctid = cp->tcp.mctid;
41
 
42
 	tile->numlyrs = cp->tcp.numlyrs;
43
-	if (!(tile->lyrsizes = jas_malloc(tile->numlyrs *
44
+	if (!(tile->lyrsizes = jas_alloc2(tile->numlyrs,
45
 	  sizeof(uint_fast32_t)))) {
46
 		goto error;
47
 	}
48
@@ -1964,7 +1964,7 @@
49
 	}
50
 
51
 	/* Allocate an array for the per-tile-component information. */
52
-	if (!(tile->tcmpts = jas_malloc(cp->numcmpts * sizeof(jpc_enc_tcmpt_t)))) {
53
+	if (!(tile->tcmpts = jas_alloc2(cp->numcmpts, sizeof(jpc_enc_tcmpt_t)))) {
54
 		goto error;
55
 	}
56
 	/* Initialize a few members critical for error recovery. */
57
@@ -2110,7 +2110,7 @@
58
 	  jas_seq2d_ystart(tcmpt->data), jas_seq2d_xend(tcmpt->data),
59
 	  jas_seq2d_yend(tcmpt->data), bandinfos);
60
 
61
-	if (!(tcmpt->rlvls = jas_malloc(tcmpt->numrlvls * sizeof(jpc_enc_rlvl_t)))) {
62
+	if (!(tcmpt->rlvls = jas_alloc2(tcmpt->numrlvls, sizeof(jpc_enc_rlvl_t)))) {
63
 		goto error;
64
 	}
65
 	for (rlvlno = 0, rlvl = tcmpt->rlvls; rlvlno < tcmpt->numrlvls;
66
@@ -2213,7 +2213,7 @@
67
 	rlvl->numvprcs = JPC_FLOORDIVPOW2(brprcbry - tlprctly, rlvl->prcheightexpn);
68
 	rlvl->numprcs = rlvl->numhprcs * rlvl->numvprcs;
69
 
70
-	if (!(rlvl->bands = jas_malloc(rlvl->numbands * sizeof(jpc_enc_band_t)))) {
71
+	if (!(rlvl->bands = jas_alloc2(rlvl->numbands, sizeof(jpc_enc_band_t)))) {
72
 		goto error;
73
 	}
74
 	for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands;
75
@@ -2290,7 +2290,7 @@
76
 	band->synweight = bandinfo->synenergywt;
77
 
78
 if (band->data) {
79
-	if (!(band->prcs = jas_malloc(rlvl->numprcs * sizeof(jpc_enc_prc_t)))) {
80
+	if (!(band->prcs = jas_alloc2(rlvl->numprcs, sizeof(jpc_enc_prc_t)))) {
81
 		goto error;
82
 	}
83
 	for (prcno = 0, prc = band->prcs; prcno < rlvl->numprcs; ++prcno,
84
@@ -2422,7 +2422,7 @@
85
 			goto error;
86
 		}
87
 
88
-		if (!(prc->cblks = jas_malloc(prc->numcblks * sizeof(jpc_enc_cblk_t)))) {
89
+		if (!(prc->cblks = jas_alloc2(prc->numcblks, sizeof(jpc_enc_cblk_t)))) {
90
 			goto error;
91
 		}
92
 		for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks;
(-)files/patch-src__libjasper__jpc__jpc_mqdec.c (+11 lines)
Added Link Here
1
--- ./src/libjasper/jpc/jpc_mqdec.c.orig	2007-01-19 21:43:07.000000000 +0000
2
+++ ./src/libjasper/jpc/jpc_mqdec.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -118,7 +118,7 @@
4
 	mqdec->in = in;
5
 	mqdec->maxctxs = maxctxs;
6
 	/* Allocate memory for the per-context state information. */
7
-	if (!(mqdec->ctxs = jas_malloc(mqdec->maxctxs * sizeof(jpc_mqstate_t *)))) {
8
+	if (!(mqdec->ctxs = jas_alloc2(mqdec->maxctxs, sizeof(jpc_mqstate_t *)))) {
9
 		goto error;
10
 	}
11
 	/* Set the current context to the first context. */
(-)files/patch-src__libjasper__jpc__jpc_mqenc.c (+11 lines)
Added Link Here
1
--- ./src/libjasper/jpc/jpc_mqenc.c.orig	2007-01-19 21:43:07.000000000 +0000
2
+++ ./src/libjasper/jpc/jpc_mqenc.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -197,7 +197,7 @@
4
 	mqenc->maxctxs = maxctxs;
5
 
6
 	/* Allocate memory for the per-context state information. */
7
-	if (!(mqenc->ctxs = jas_malloc(mqenc->maxctxs * sizeof(jpc_mqstate_t *)))) {
8
+	if (!(mqenc->ctxs = jas_alloc2(mqenc->maxctxs, sizeof(jpc_mqstate_t *)))) {
9
 		goto error;
10
 	}
11
 
(-)files/patch-src__libjasper__jpc__jpc_qmfb.c (+74 lines)
Added Link Here
1
--- ./src/libjasper/jpc/jpc_qmfb.c.orig	2007-01-19 21:43:07.000000000 +0000
2
+++ ./src/libjasper/jpc/jpc_qmfb.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -321,7 +321,7 @@
4
 #if !defined(HAVE_VLA)
5
 	/* Get a buffer. */
6
 	if (bufsize > QMFB_SPLITBUFSIZE) {
7
-		if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
8
+		if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
9
 			/* We have no choice but to commit suicide in this case. */
10
 			abort();
11
 		}
12
@@ -389,7 +389,7 @@
13
 #if !defined(HAVE_VLA)
14
 	/* Get a buffer. */
15
 	if (bufsize > QMFB_SPLITBUFSIZE) {
16
-		if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
17
+		if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
18
 			/* We have no choice but to commit suicide in this case. */
19
 			abort();
20
 		}
21
@@ -460,7 +460,7 @@
22
 #if !defined(HAVE_VLA)
23
 	/* Get a buffer. */
24
 	if (bufsize > QMFB_SPLITBUFSIZE) {
25
-		if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
26
+		if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
27
 			/* We have no choice but to commit suicide in this case. */
28
 			abort();
29
 		}
30
@@ -549,7 +549,7 @@
31
 #if !defined(HAVE_VLA)
32
 	/* Get a buffer. */
33
 	if (bufsize > QMFB_SPLITBUFSIZE) {
34
-		if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
35
+		if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
36
 			/* We have no choice but to commit suicide in this case. */
37
 			abort();
38
 		}
39
@@ -633,7 +633,7 @@
40
 #if !defined(HAVE_VLA)
41
 	/* Allocate memory for the join buffer from the heap. */
42
 	if (bufsize > QMFB_JOINBUFSIZE) {
43
-		if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
44
+		if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
45
 			/* We have no choice but to commit suicide. */
46
 			abort();
47
 		}
48
@@ -698,7 +698,7 @@
49
 #if !defined(HAVE_VLA)
50
 	/* Allocate memory for the join buffer from the heap. */
51
 	if (bufsize > QMFB_JOINBUFSIZE) {
52
-		if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
53
+		if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
54
 			/* We have no choice but to commit suicide. */
55
 			abort();
56
 		}
57
@@ -766,7 +766,7 @@
58
 #if !defined(HAVE_VLA)
59
 	/* Allocate memory for the join buffer from the heap. */
60
 	if (bufsize > QMFB_JOINBUFSIZE) {
61
-		if (!(buf = jas_malloc(bufsize * JPC_QMFB_COLGRPSIZE * sizeof(jpc_fix_t)))) {
62
+		if (!(buf = jas_alloc2(bufsize, JPC_QMFB_COLGRPSIZE * sizeof(jpc_fix_t)))) {
63
 			/* We have no choice but to commit suicide. */
64
 			abort();
65
 		}
66
@@ -852,7 +852,7 @@
67
 #if !defined(HAVE_VLA)
68
 	/* Allocate memory for the join buffer from the heap. */
69
 	if (bufsize > QMFB_JOINBUFSIZE) {
70
-		if (!(buf = jas_malloc(bufsize * numcols * sizeof(jpc_fix_t)))) {
71
+		if (!(buf = jas_alloc3(bufsize, numcols, sizeof(jpc_fix_t)))) {
72
 			/* We have no choice but to commit suicide. */
73
 			abort();
74
 		}
(-)files/patch-src__libjasper__jpc__jpc_t1enc.c (+11 lines)
Added Link Here
1
--- ./src/libjasper/jpc/jpc_t1enc.c.orig	2007-01-19 21:43:07.000000000 +0000
2
+++ ./src/libjasper/jpc/jpc_t1enc.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -219,7 +219,7 @@
4
 
5
 	cblk->numpasses = (cblk->numbps > 0) ? (3 * cblk->numbps - 2) : 0;
6
 	if (cblk->numpasses > 0) {
7
-		cblk->passes = jas_malloc(cblk->numpasses * sizeof(jpc_enc_pass_t));
8
+		cblk->passes = jas_alloc2(cblk->numpasses, sizeof(jpc_enc_pass_t));
9
 		assert(cblk->passes);
10
 	} else {
11
 		cblk->passes = 0;
(-)files/patch-src__libjasper__jpc__jpc_t2cod.c (+11 lines)
Added Link Here
1
--- ./src/libjasper/jpc/jpc_t2cod.c.orig	2007-01-19 21:43:07.000000000 +0000
2
+++ ./src/libjasper/jpc/jpc_t2cod.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -573,7 +573,7 @@
4
 	}
5
 	if (pchglist->numpchgs >= pchglist->maxpchgs) {
6
 		newmaxpchgs = pchglist->maxpchgs + 128;
7
-		if (!(newpchgs = jas_realloc(pchglist->pchgs, newmaxpchgs * sizeof(jpc_pchg_t *)))) {
8
+		if (!(newpchgs = jas_realloc2(pchglist->pchgs, newmaxpchgs, sizeof(jpc_pchg_t *)))) {
9
 			return -1;
10
 		}
11
 		pchglist->maxpchgs = newmaxpchgs;
(-)files/patch-src__libjasper__jpc__jpc_t2dec.c (+29 lines)
Added Link Here
1
--- ./src/libjasper/jpc/jpc_t2dec.c.orig	2007-01-19 21:43:07.000000000 +0000
2
+++ ./src/libjasper/jpc/jpc_t2dec.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -478,7 +478,7 @@
4
 		return 0;
5
 	}
6
 	pi->numcomps = dec->numcomps;
7
-	if (!(pi->picomps = jas_malloc(pi->numcomps * sizeof(jpc_picomp_t)))) {
8
+	if (!(pi->picomps = jas_alloc2(pi->numcomps, sizeof(jpc_picomp_t)))) {
9
 		jpc_pi_destroy(pi);
10
 		return 0;
11
 	}
12
@@ -490,7 +490,7 @@
13
 	for (compno = 0, tcomp = tile->tcomps, picomp = pi->picomps;
14
 	  compno < pi->numcomps; ++compno, ++tcomp, ++picomp) {
15
 		picomp->numrlvls = tcomp->numrlvls;
16
-		if (!(picomp->pirlvls = jas_malloc(picomp->numrlvls *
17
+		if (!(picomp->pirlvls = jas_alloc2(picomp->numrlvls,
18
 		  sizeof(jpc_pirlvl_t)))) {
19
 			jpc_pi_destroy(pi);
20
 			return 0;
21
@@ -503,7 +503,7 @@
22
 		  rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) {
23
 /* XXX sizeof(long) should be sizeof different type */
24
 			pirlvl->numprcs = rlvl->numprcs;
25
-			if (!(pirlvl->prclyrnos = jas_malloc(pirlvl->numprcs *
26
+			if (!(pirlvl->prclyrnos = jas_alloc2(pirlvl->numprcs,
27
 			  sizeof(long)))) {
28
 				jpc_pi_destroy(pi);
29
 				return 0;
(-)files/patch-src__libjasper__jpc__jpc_t2enc.c (+29 lines)
Added Link Here
1
--- ./src/libjasper/jpc/jpc_t2enc.c.orig	2007-01-19 21:43:07.000000000 +0000
2
+++ ./src/libjasper/jpc/jpc_t2enc.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -565,7 +565,7 @@
4
 	}
5
 	pi->pktno = -1;
6
 	pi->numcomps = cp->numcmpts;
7
-	if (!(pi->picomps = jas_malloc(pi->numcomps * sizeof(jpc_picomp_t)))) {
8
+	if (!(pi->picomps = jas_alloc2(pi->numcomps, sizeof(jpc_picomp_t)))) {
9
 		jpc_pi_destroy(pi);
10
 		return 0;
11
 	}
12
@@ -577,7 +577,7 @@
13
 	for (compno = 0, tcomp = tile->tcmpts, picomp = pi->picomps;
14
 	  compno < pi->numcomps; ++compno, ++tcomp, ++picomp) {
15
 		picomp->numrlvls = tcomp->numrlvls;
16
-		if (!(picomp->pirlvls = jas_malloc(picomp->numrlvls *
17
+		if (!(picomp->pirlvls = jas_alloc2(picomp->numrlvls,
18
 		  sizeof(jpc_pirlvl_t)))) {
19
 			jpc_pi_destroy(pi);
20
 			return 0;
21
@@ -591,7 +591,7 @@
22
 /* XXX sizeof(long) should be sizeof different type */
23
 			pirlvl->numprcs = rlvl->numprcs;
24
 			if (rlvl->numprcs) {
25
-				if (!(pirlvl->prclyrnos = jas_malloc(pirlvl->numprcs *
26
+				if (!(pirlvl->prclyrnos = jas_alloc2(pirlvl->numprcs,
27
 				  sizeof(long)))) {
28
 					jpc_pi_destroy(pi);
29
 					return 0;
(-)files/patch-src__libjasper__jpc__jpc_tagtree.c (+11 lines)
Added Link Here
1
--- ./src/libjasper/jpc/jpc_tagtree.c.orig	2007-01-19 21:43:07.000000000 +0000
2
+++ ./src/libjasper/jpc/jpc_tagtree.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -125,7 +125,7 @@
4
 		++numlvls;
5
 	} while (n > 1);
6
 
7
-	if (!(tree->nodes_ = jas_malloc(tree->numnodes_ * sizeof(jpc_tagtreenode_t)))) {
8
+	if (!(tree->nodes_ = jas_alloc2(tree->numnodes_, sizeof(jpc_tagtreenode_t)))) {
9
 		return 0;
10
 	}
11
 
(-)files/patch-src__libjasper__jpc__jpc_util.c (+11 lines)
Added Link Here
1
--- ./src/libjasper/jpc/jpc_util.c.orig	2007-01-19 21:43:07.000000000 +0000
2
+++ ./src/libjasper/jpc/jpc_util.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -109,7 +109,7 @@
4
 	}
5
 
6
 	if (n) {
7
-		if (!(vs = jas_malloc(n * sizeof(double)))) {
8
+		if (!(vs = jas_alloc2(n, sizeof(double)))) {
9
 			return -1;
10
 		}
11
 
(-)files/patch-src__libjasper__mif__mif_cod.c (+12 lines)
Added Link Here
1
--- ./src/libjasper/mif/mif_cod.c.orig	2007-01-19 21:43:05.000000000 +0000
2
+++ ./src/libjasper/mif/mif_cod.c	2011-12-30 03:00:54.000000000 +0000
3
@@ -438,8 +438,7 @@
4
 	int cmptno;
5
 	mif_cmpt_t **newcmpts;
6
 	assert(maxcmpts >= hdr->numcmpts);
7
-	newcmpts = (!hdr->cmpts) ? jas_malloc(maxcmpts * sizeof(mif_cmpt_t *)) :
8
-	  jas_realloc(hdr->cmpts, maxcmpts * sizeof(mif_cmpt_t *));
9
+	newcmpts = jas_realloc2(hdr->cmpts, maxcmpts, sizeof(mif_cmpt_t *));
10
 	if (!newcmpts) {
11
 		return -1;
12
 	}

Return to bug 163718