425a81
diff -up jasper-1.900.1/src/libjasper/jpc/jpc_qmfb.c.CVE-2014-8158 jasper-1.900.1/src/libjasper/jpc/jpc_qmfb.c
425a81
--- jasper-1.900.1/src/libjasper/jpc/jpc_qmfb.c.CVE-2014-8158	2015-01-19 17:25:28.730195502 +0100
425a81
+++ jasper-1.900.1/src/libjasper/jpc/jpc_qmfb.c	2015-01-19 17:27:20.214663127 +0100
425a81
@@ -306,11 +306,7 @@ void jpc_qmfb_split_row(jpc_fix_t *a, in
425a81
 {
425a81
 
425a81
 	int bufsize = JPC_CEILDIVPOW2(numcols, 1);
425a81
-#if !defined(HAVE_VLA)
425a81
 	jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE];
425a81
-#else
425a81
-	jpc_fix_t splitbuf[bufsize];
425a81
-#endif
425a81
 	jpc_fix_t *buf = splitbuf;
425a81
 	register jpc_fix_t *srcptr;
425a81
 	register jpc_fix_t *dstptr;
425a81
@@ -318,7 +314,6 @@ void jpc_qmfb_split_row(jpc_fix_t *a, in
425a81
 	register int m;
425a81
 	int hstartcol;
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* Get a buffer. */
425a81
 	if (bufsize > QMFB_SPLITBUFSIZE) {
425a81
 		if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
425a81
@@ -326,7 +321,6 @@ void jpc_qmfb_split_row(jpc_fix_t *a, in
425a81
 			abort();
425a81
 		}
425a81
 	}
425a81
-#endif
425a81
 
425a81
 	if (numcols >= 2) {
425a81
 		hstartcol = (numcols + 1 - parity) >> 1;
425a81
@@ -360,12 +354,10 @@ void jpc_qmfb_split_row(jpc_fix_t *a, in
425a81
 		}
425a81
 	}
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* If the split buffer was allocated on the heap, free this memory. */
425a81
 	if (buf != splitbuf) {
425a81
 		jas_free(buf);
425a81
 	}
425a81
-#endif
425a81
 
425a81
 }
425a81
 
425a81
@@ -374,11 +366,7 @@ void jpc_qmfb_split_col(jpc_fix_t *a, in
425a81
 {
425a81
 
425a81
 	int bufsize = JPC_CEILDIVPOW2(numrows, 1);
425a81
-#if !defined(HAVE_VLA)
425a81
 	jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE];
425a81
-#else
425a81
-	jpc_fix_t splitbuf[bufsize];
425a81
-#endif
425a81
 	jpc_fix_t *buf = splitbuf;
425a81
 	register jpc_fix_t *srcptr;
425a81
 	register jpc_fix_t *dstptr;
425a81
@@ -386,7 +374,6 @@ void jpc_qmfb_split_col(jpc_fix_t *a, in
425a81
 	register int m;
425a81
 	int hstartcol;
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* Get a buffer. */
425a81
 	if (bufsize > QMFB_SPLITBUFSIZE) {
425a81
 		if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
425a81
@@ -394,7 +381,6 @@ void jpc_qmfb_split_col(jpc_fix_t *a, in
425a81
 			abort();
425a81
 		}
425a81
 	}
425a81
-#endif
425a81
 
425a81
 	if (numrows >= 2) {
425a81
 		hstartcol = (numrows + 1 - parity) >> 1;
425a81
@@ -428,12 +414,10 @@ void jpc_qmfb_split_col(jpc_fix_t *a, in
425a81
 		}
425a81
 	}
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* If the split buffer was allocated on the heap, free this memory. */
425a81
 	if (buf != splitbuf) {
425a81
 		jas_free(buf);
425a81
 	}
425a81
-#endif
425a81
 
425a81
 }
425a81
 
425a81
@@ -442,11 +426,7 @@ void jpc_qmfb_split_colgrp(jpc_fix_t *a,
425a81
 {
425a81
 
425a81
 	int bufsize = JPC_CEILDIVPOW2(numrows, 1);
425a81
-#if !defined(HAVE_VLA)
425a81
 	jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE * JPC_QMFB_COLGRPSIZE];
425a81
-#else
425a81
-	jpc_fix_t splitbuf[bufsize * JPC_QMFB_COLGRPSIZE];
425a81
-#endif
425a81
 	jpc_fix_t *buf = splitbuf;
425a81
 	jpc_fix_t *srcptr;
425a81
 	jpc_fix_t *dstptr;
425a81
@@ -457,7 +437,6 @@ void jpc_qmfb_split_colgrp(jpc_fix_t *a,
425a81
 	int m;
425a81
 	int hstartcol;
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* Get a buffer. */
425a81
 	if (bufsize > QMFB_SPLITBUFSIZE) {
425a81
 		if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
425a81
@@ -465,7 +444,6 @@ void jpc_qmfb_split_colgrp(jpc_fix_t *a,
425a81
 			abort();
425a81
 		}
425a81
 	}
425a81
-#endif
425a81
 
425a81
 	if (numrows >= 2) {
425a81
 		hstartcol = (numrows + 1 - parity) >> 1;
425a81
@@ -517,12 +495,10 @@ void jpc_qmfb_split_colgrp(jpc_fix_t *a,
425a81
 		}
425a81
 	}
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* If the split buffer was allocated on the heap, free this memory. */
425a81
 	if (buf != splitbuf) {
425a81
 		jas_free(buf);
425a81
 	}
425a81
-#endif
425a81
 
425a81
 }
425a81
 
425a81
@@ -531,11 +507,7 @@ void jpc_qmfb_split_colres(jpc_fix_t *a,
425a81
 {
425a81
 
425a81
 	int bufsize = JPC_CEILDIVPOW2(numrows, 1);
425a81
-#if !defined(HAVE_VLA)
425a81
 	jpc_fix_t splitbuf[QMFB_SPLITBUFSIZE * JPC_QMFB_COLGRPSIZE];
425a81
-#else
425a81
-	jpc_fix_t splitbuf[bufsize * numcols];
425a81
-#endif
425a81
 	jpc_fix_t *buf = splitbuf;
425a81
 	jpc_fix_t *srcptr;
425a81
 	jpc_fix_t *dstptr;
425a81
@@ -546,7 +518,6 @@ void jpc_qmfb_split_colres(jpc_fix_t *a,
425a81
 	int m;
425a81
 	int hstartcol;
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* Get a buffer. */
425a81
 	if (bufsize > QMFB_SPLITBUFSIZE) {
425a81
 		if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
425a81
@@ -554,7 +525,6 @@ void jpc_qmfb_split_colres(jpc_fix_t *a,
425a81
 			abort();
425a81
 		}
425a81
 	}
425a81
-#endif
425a81
 
425a81
 	if (numrows >= 2) {
425a81
 		hstartcol = (numrows + 1 - parity) >> 1;
425a81
@@ -606,12 +576,10 @@ void jpc_qmfb_split_colres(jpc_fix_t *a,
425a81
 		}
425a81
 	}
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* If the split buffer was allocated on the heap, free this memory. */
425a81
 	if (buf != splitbuf) {
425a81
 		jas_free(buf);
425a81
 	}
425a81
-#endif
425a81
 
425a81
 }
425a81
 
425a81
@@ -619,18 +587,13 @@ void jpc_qmfb_join_row(jpc_fix_t *a, int
425a81
 {
425a81
 
425a81
 	int bufsize = JPC_CEILDIVPOW2(numcols, 1);
425a81
-#if !defined(HAVE_VLA)
425a81
 	jpc_fix_t joinbuf[QMFB_JOINBUFSIZE];
425a81
-#else
425a81
-	jpc_fix_t joinbuf[bufsize];
425a81
-#endif
425a81
 	jpc_fix_t *buf = joinbuf;
425a81
 	register jpc_fix_t *srcptr;
425a81
 	register jpc_fix_t *dstptr;
425a81
 	register int n;
425a81
 	int hstartcol;
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* Allocate memory for the join buffer from the heap. */
425a81
 	if (bufsize > QMFB_JOINBUFSIZE) {
425a81
 		if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
425a81
@@ -638,7 +601,6 @@ void jpc_qmfb_join_row(jpc_fix_t *a, int
425a81
 			abort();
425a81
 		}
425a81
 	}
425a81
-#endif
425a81
 
425a81
 	hstartcol = (numcols + 1 - parity) >> 1;
425a81
 
425a81
@@ -670,12 +632,10 @@ void jpc_qmfb_join_row(jpc_fix_t *a, int
425a81
 		++srcptr;
425a81
 	}
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* If the join buffer was allocated on the heap, free this memory. */
425a81
 	if (buf != joinbuf) {
425a81
 		jas_free(buf);
425a81
 	}
425a81
-#endif
425a81
 
425a81
 }
425a81
 
425a81
@@ -684,18 +644,13 @@ void jpc_qmfb_join_col(jpc_fix_t *a, int
425a81
 {
425a81
 
425a81
 	int bufsize = JPC_CEILDIVPOW2(numrows, 1);
425a81
-#if !defined(HAVE_VLA)
425a81
 	jpc_fix_t joinbuf[QMFB_JOINBUFSIZE];
425a81
-#else
425a81
-	jpc_fix_t joinbuf[bufsize];
425a81
-#endif
425a81
 	jpc_fix_t *buf = joinbuf;
425a81
 	register jpc_fix_t *srcptr;
425a81
 	register jpc_fix_t *dstptr;
425a81
 	register int n;
425a81
 	int hstartcol;
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* Allocate memory for the join buffer from the heap. */
425a81
 	if (bufsize > QMFB_JOINBUFSIZE) {
425a81
 		if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
425a81
@@ -703,7 +658,6 @@ void jpc_qmfb_join_col(jpc_fix_t *a, int
425a81
 			abort();
425a81
 		}
425a81
 	}
425a81
-#endif
425a81
 
425a81
 	hstartcol = (numrows + 1 - parity) >> 1;
425a81
 
425a81
@@ -735,12 +689,10 @@ void jpc_qmfb_join_col(jpc_fix_t *a, int
425a81
 		++srcptr;
425a81
 	}
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* If the join buffer was allocated on the heap, free this memory. */
425a81
 	if (buf != joinbuf) {
425a81
 		jas_free(buf);
425a81
 	}
425a81
-#endif
425a81
 
425a81
 }
425a81
 
425a81
@@ -749,11 +701,7 @@ void jpc_qmfb_join_colgrp(jpc_fix_t *a,
425a81
 {
425a81
 
425a81
 	int bufsize = JPC_CEILDIVPOW2(numrows, 1);
425a81
-#if !defined(HAVE_VLA)
425a81
 	jpc_fix_t joinbuf[QMFB_JOINBUFSIZE * JPC_QMFB_COLGRPSIZE];
425a81
-#else
425a81
-	jpc_fix_t joinbuf[bufsize * JPC_QMFB_COLGRPSIZE];
425a81
-#endif
425a81
 	jpc_fix_t *buf = joinbuf;
425a81
 	jpc_fix_t *srcptr;
425a81
 	jpc_fix_t *dstptr;
425a81
@@ -763,7 +711,6 @@ void jpc_qmfb_join_colgrp(jpc_fix_t *a,
425a81
 	register int i;
425a81
 	int hstartcol;
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* Allocate memory for the join buffer from the heap. */
425a81
 	if (bufsize > QMFB_JOINBUFSIZE) {
425a81
 		if (!(buf = jas_alloc2(bufsize, JPC_QMFB_COLGRPSIZE * sizeof(jpc_fix_t)))) {
425a81
@@ -771,7 +718,6 @@ void jpc_qmfb_join_colgrp(jpc_fix_t *a,
425a81
 			abort();
425a81
 		}
425a81
 	}
425a81
-#endif
425a81
 
425a81
 	hstartcol = (numrows + 1 - parity) >> 1;
425a81
 
425a81
@@ -821,12 +767,10 @@ void jpc_qmfb_join_colgrp(jpc_fix_t *a,
425a81
 		srcptr += JPC_QMFB_COLGRPSIZE;
425a81
 	}
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* If the join buffer was allocated on the heap, free this memory. */
425a81
 	if (buf != joinbuf) {
425a81
 		jas_free(buf);
425a81
 	}
425a81
-#endif
425a81
 
425a81
 }
425a81
 
425a81
@@ -835,11 +779,7 @@ void jpc_qmfb_join_colres(jpc_fix_t *a,
425a81
 {
425a81
 
425a81
 	int bufsize = JPC_CEILDIVPOW2(numrows, 1);
425a81
-#if !defined(HAVE_VLA)
425a81
 	jpc_fix_t joinbuf[QMFB_JOINBUFSIZE * JPC_QMFB_COLGRPSIZE];
425a81
-#else
425a81
-	jpc_fix_t joinbuf[bufsize * numcols];
425a81
-#endif
425a81
 	jpc_fix_t *buf = joinbuf;
425a81
 	jpc_fix_t *srcptr;
425a81
 	jpc_fix_t *dstptr;
425a81
@@ -849,7 +789,6 @@ void jpc_qmfb_join_colres(jpc_fix_t *a,
425a81
 	register int i;
425a81
 	int hstartcol;
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* Allocate memory for the join buffer from the heap. */
425a81
 	if (bufsize > QMFB_JOINBUFSIZE) {
425a81
 		if (!(buf = jas_alloc3(bufsize, numcols, sizeof(jpc_fix_t)))) {
425a81
@@ -857,7 +796,6 @@ void jpc_qmfb_join_colres(jpc_fix_t *a,
425a81
 			abort();
425a81
 		}
425a81
 	}
425a81
-#endif
425a81
 
425a81
 	hstartcol = (numrows + 1 - parity) >> 1;
425a81
 
425a81
@@ -907,12 +845,10 @@ void jpc_qmfb_join_colres(jpc_fix_t *a,
425a81
 		srcptr += numcols;
425a81
 	}
425a81
 
425a81
-#if !defined(HAVE_VLA)
425a81
 	/* If the join buffer was allocated on the heap, free this memory. */
425a81
 	if (buf != joinbuf) {
425a81
 		jas_free(buf);
425a81
 	}
425a81
-#endif
425a81
 
425a81
 }
425a81