Fixed compiler warnings (errors)

This commit is contained in:
mpetavy 2018-07-19 11:12:19 +02:00 committed by GitHub
parent ffb7667593
commit 785199d351
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -41,6 +41,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <malloc.h>
#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;
}