mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
[g2clib] Fix memory leaks
This commit is contained in:
@@ -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;
|
||||
}
|
||||
//
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user