From 785199d3513a4c3a6fe43ecc1f93195111f2c76f Mon Sep 17 00:00:00 2001 From: mpetavy Date: Thu, 19 Jul 2018 11:12:19 +0200 Subject: [PATCH] Fixed compiler warnings (errors) --- src/bin/jp2/convertbmp.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bin/jp2/convertbmp.c b/src/bin/jp2/convertbmp.c index ee2a8d7d..76a5d654 100644 --- a/src/bin/jp2/convertbmp.c +++ b/src/bin/jp2/convertbmp.c @@ -41,6 +41,7 @@ #include #include #include +#include #include "openjpeg.h" #include "convert.h" @@ -660,7 +661,8 @@ static OPJ_BOOL bmp_read_rle4_data(FILE* IN, OPJ_UINT8* pData, opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters) { - opj_image_cmptparm_t cmptparm[4]; /* maximum of 4 components */ + opj_image_cmptparm_t cmptparm[4]; /* + imum of 4 components */ OPJ_UINT8 lut_R[256], lut_G[256], lut_B[256]; OPJ_UINT8 const* pLUT[3]; opj_image_t * image = NULL; @@ -862,6 +864,8 @@ int imagetobmp(opj_image_t * image, const char *outfile) int i, pad; FILE *fdest = NULL; int adjustR, adjustG, adjustB; + OPJ_UINT8 *pBuffer = (OPJ_UINT8 *) calloc(1, 1024*1024); + OPJ_SIZE_T c = 0; if (image->comps[0].prec < 8) { fprintf(stderr, "imagetobmp: Unsupported precision: %d\n", @@ -955,10 +959,6 @@ int imagetobmp(opj_image_t * image, const char *outfile) adjustB = 0; } - int max = 1024*1024; - OPJ_UINT8 *pBuffer = (OPJ_UINT8 *) calloc(1, max); - int c = 0; - for (i = 0; i < w * h; i++) { OPJ_UINT8 rc, gc, bc; int r, g, b; @@ -999,7 +999,7 @@ int imagetobmp(opj_image_t * image, const char *outfile) } bc = (OPJ_UINT8)b; - if(c >= (max - 3)) { + if(c >= (malloc_usable_size(pBuffer) - 3)) { fwrite(pBuffer,1,c,fdest); c = 0; } @@ -1011,7 +1011,7 @@ int imagetobmp(opj_image_t * image, const char *outfile) if ((i + 1) % w == 0) { for (pad = ((3 * w) % 4) ? (4 - (3 * w) % 4) : 0; pad > 0; pad--) { /* ADD */ - if(c >= (max - 1)) { + if(c >= (malloc_usable_size(pBuffer) - 1)) { fwrite(pBuffer,1,c,fdest); c = 0; }