unlisted sec bug fix 2
[platform/upstream/jasper.git] / src / libjasper / jpc / jpc_cs.c
index e99f3ff..e6e317d 100644 (file)
@@ -502,7 +502,7 @@ static int jpc_siz_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate,
          !siz->tileheight || !siz->numcomps) {
                return -1;
        }
-       if (!(siz->comps = jas_malloc(siz->numcomps * sizeof(jpc_sizcomp_t)))) {
+       if (!(siz->comps = jas_alloc2(siz->numcomps, sizeof(jpc_sizcomp_t)))) {
                return -1;
        }
        for (i = 0; i < siz->numcomps; ++i) {
@@ -986,7 +986,7 @@ static int jpc_qcx_getcompparms(jpc_qcxcp_t *compparms, jpc_cstate_t *cstate,
                jpc_qcx_destroycompparms(compparms);
                 return -1;
         } else if (compparms->numstepsizes > 0) {
-               compparms->stepsizes = jas_malloc(compparms->numstepsizes *
+               compparms->stepsizes = jas_alloc2(compparms->numstepsizes,
                  sizeof(uint_fast16_t));
                assert(compparms->stepsizes);
                for (i = 0; i < compparms->numstepsizes; ++i) {
@@ -1094,7 +1094,7 @@ static int jpc_ppm_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in
 
        ppm->len = ms->len - 1;
        if (ppm->len > 0) {
-               if (!(ppm->data = jas_malloc(ppm->len * sizeof(unsigned char)))) {
+               if (!(ppm->data = jas_malloc(ppm->len))) {
                        goto error;
                }
                if (JAS_CAST(uint, jas_stream_read(in, ppm->data, ppm->len)) != ppm->len) {
@@ -1163,7 +1163,7 @@ static int jpc_ppt_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in
        }
        ppt->len = ms->len - 1;
        if (ppt->len > 0) {
-               if (!(ppt->data = jas_malloc(ppt->len * sizeof(unsigned char)))) {
+               if (!(ppt->data = jas_malloc(ppt->len))) {
                        goto error;
                }
                if (jas_stream_read(in, (char *) ppt->data, ppt->len) != JAS_CAST(int, ppt->len)) {
@@ -1226,7 +1226,7 @@ static int jpc_poc_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in
        uint_fast8_t tmp;
        poc->numpchgs = (cstate->numcomps > 256) ? (ms->len / 9) :
          (ms->len / 7);
-       if (!(poc->pchgs = jas_malloc(poc->numpchgs * sizeof(jpc_pocpchg_t)))) {
+       if (!(poc->pchgs = jas_alloc2(poc->numpchgs, sizeof(jpc_pocpchg_t)))) {
                goto error;
        }
        for (pchgno = 0, pchg = poc->pchgs; pchgno < poc->numpchgs; ++pchgno,
@@ -1331,7 +1331,7 @@ static int jpc_crg_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in
        jpc_crgcomp_t *comp;
        uint_fast16_t compno;
        crg->numcomps = cstate->numcomps;
-       if (!(crg->comps = jas_malloc(cstate->numcomps * sizeof(uint_fast16_t)))) {
+       if (!(crg->comps = jas_alloc2(cstate->numcomps, sizeof(uint_fast16_t)))) {
                return -1;
        }
        for (compno = 0, comp = crg->comps; compno < cstate->numcomps;
@@ -1470,7 +1470,7 @@ static int jpc_unk_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in
        cstate = 0;
 
        if (ms->len > 0) {
-               if (!(unk->data = jas_malloc(ms->len * sizeof(unsigned char)))) {
+               if (!(unk->data = jas_malloc(ms->len))) {
                        return -1;
                }
                if (jas_stream_read(in, (char *) unk->data, ms->len) != JAS_CAST(int, ms->len)) {