summaryrefslogtreecommitdiff
path: root/src/bin/jp2/convert.c
diff options
context:
space:
mode:
authorjulienmalik <julienmalik@users.noreply.github.com>2016-04-29 23:49:17 +0200
committerMatthieu Darbois <mayeut@users.noreply.github.com>2016-04-29 23:49:17 +0200
commit319fc971fef8a1e1c1c543506c26805873e3f258 (patch)
tree9c17957f208bffbf04276bdd012cd8428209e377 /src/bin/jp2/convert.c
parente166e4a209d9a3e4b583e4b2cdcbab2c57967eb1 (diff)
cppcheck fix for openjp2 (#740)
Diffstat (limited to 'src/bin/jp2/convert.c')
-rw-r--r--src/bin/jp2/convert.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c
index 13713204..940ac2fa 100644
--- a/src/bin/jp2/convert.c
+++ b/src/bin/jp2/convert.c
@@ -611,6 +611,10 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
if (id_len)
{
unsigned char *id = (unsigned char *) malloc(id_len);
+ if(id == 0){
+ fprintf(stderr, "tga_readheader: memory out\n");
+ return 0;
+ }
if ( !fread(id, id_len, 1, fp) )
{
fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
@@ -1249,6 +1253,7 @@ int imagetopgx(opj_image_t * image, const char *outfile)
{
name = (char*)malloc(total+1);
if (name == NULL) {
+ fprintf(stderr, "imagetopgx: memory out\n");
goto fin;
}
}
@@ -1906,7 +1911,11 @@ if(v > 65535) v = 65535; else if(v < 0) v = 0;
fprintf(stderr," is written to the file\n");
}
destname = (char*)malloc(strlen(outfile) + 8);
-
+ if(destname == NULL){
+ fprintf(stderr, "imagetopnm: memory out\n");
+ fclose(fdest);
+ return 1;
+ }
for (compno = 0; compno < ncomp; compno++)
{
if (ncomp > 1)