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