[g2clib] Fix memory leaks

This commit is contained in:
Roland Winklmeier
2016-01-11 17:54:17 +01:00
parent f4f5999595
commit 7d88bdd43b
2 changed files with 8 additions and 0 deletions

View File

@@ -201,9 +201,15 @@ int comunpack(unsigned char *cpack,g2int lensec,g2int idrsnum,g2int *idrstmpl,g2
totLen += glen[j];
}
if (totLen != ndpts) {
free(ifld);
free(gref);
free(gwidth);
return 1;
}
if (totBit / 8. > lensec) {
free(ifld);
free(gref);
free(gwidth);
return 1;
}
//

View File

@@ -58,6 +58,8 @@ g2int pngunpack(unsigned char *cpack,g2int len,g2int *idrstmpl,g2int ndpts,
ctemp=(unsigned char *)calloc(ndpts*4,1);
if ( ifld == 0 || ctemp == 0) {
fprintf(stderr,"Could not allocate space in jpcunpack.\n Data field NOT upacked.\n");
if ( ctemp != 0 ) free(ctemp);
if ( ifld != 0 ) free(ifld);
return(1);
}
dec_png(cpack,&width,&height,ctemp);