diff options
Diffstat (limited to 'src/bin/jp2/convertbmp.c')
| -rw-r--r-- | src/bin/jp2/convertbmp.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/bin/jp2/convertbmp.c b/src/bin/jp2/convertbmp.c index 1131a599..910574b8 100644 --- a/src/bin/jp2/convertbmp.c +++ b/src/bin/jp2/convertbmp.c @@ -572,7 +572,7 @@ static OPJ_BOOL bmp_read_rle4_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride OPJ_UINT8 c1 = (OPJ_UINT8)getc(IN); for (j = 0; (j < c) && (x < width) && ((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) { - *pix = (j&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f); + *pix = (OPJ_UINT8)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU)); } } else { /* absolute mode */ @@ -598,7 +598,7 @@ static OPJ_BOOL bmp_read_rle4_data(FILE* IN, OPJ_UINT8* pData, OPJ_UINT32 stride if((j&1) == 0) { c1 = (OPJ_UINT8)getc(IN); } - *pix = (j&1) ? (c1 & 0x0f) : ((c1>>4)&0x0f); + *pix = (OPJ_UINT8)((j&1) ? (c1 & 0x0fU) : ((c1>>4)&0x0fU)); } if(((c&3) == 1) || ((c&3) == 2)) { /* skip padding byte */ getc(IN); @@ -729,6 +729,7 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters) image = opj_image_create(numcmpts, &cmptparm[0], (numcmpts == 1U) ? OPJ_CLRSPC_GRAY : OPJ_CLRSPC_SRGB); if(!image) { fclose(IN); + free(pData); return NULL; } if (numcmpts == 4U) { @@ -902,6 +903,10 @@ int imagetobmp(opj_image_t * image, const char *outfile) { <<-- <<-- <<-- <<-- */ fdest = fopen(outfile, "wb"); + if (!fdest) { + fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile); + return 1; + } w = (int)image->comps[0].w; h = (int)image->comps[0].h; |
