diff options
| author | Antonin Descampe <antonin@gmail.com> | 2014-09-16 15:48:04 +0000 |
|---|---|---|
| committer | Antonin Descampe <antonin@gmail.com> | 2014-09-16 15:48:04 +0000 |
| commit | 50a205d20f25d26e77299f5bf8e62e1aa038d2b7 (patch) | |
| tree | 3a032a6f8225c02db315a862306fee857ca5f479 /src/bin/jp2/convert.c | |
| parent | b0072bf658c9294d0bd337cb3acd638d01124ee8 (diff) | |
[trunk] improve memory management (fixes issue 359)
Diffstat (limited to 'src/bin/jp2/convert.c')
| -rw-r--r-- | src/bin/jp2/convert.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c index 9ce3eb39..606238d1 100644 --- a/src/bin/jp2/convert.c +++ b/src/bin/jp2/convert.c @@ -2988,10 +2988,13 @@ static opj_image_t* rawtoimage_common(const char *filename, opj_cparameters_t *p } w = raw_cp->rawWidth; h = raw_cp->rawHeight; - cmptparm = (opj_image_cmptparm_t*) malloc((size_t)numcomps * sizeof(opj_image_cmptparm_t)); - + cmptparm = (opj_image_cmptparm_t*) calloc(numcomps,sizeof(opj_image_cmptparm_t)); + if (!cmptparm) { + fprintf(stderr, "Failed to allocate image components parameters !!\n"); + fprintf(stderr,"Aborting\n"); + return NULL; + } /* initialize image components */ - memset(&cmptparm[0], 0, (size_t)numcomps * sizeof(opj_image_cmptparm_t)); for(i = 0; i < numcomps; i++) { cmptparm[i].prec = (OPJ_UINT32)raw_cp->rawBitDepth; cmptparm[i].bpp = (OPJ_UINT32)raw_cp->rawBitDepth; |
