mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 11:05:44 +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];
|
totLen += glen[j];
|
||||||
}
|
}
|
||||||
if (totLen != ndpts) {
|
if (totLen != ndpts) {
|
||||||
|
free(ifld);
|
||||||
|
free(gref);
|
||||||
|
free(gwidth);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (totBit / 8. > lensec) {
|
if (totBit / 8. > lensec) {
|
||||||
|
free(ifld);
|
||||||
|
free(gref);
|
||||||
|
free(gwidth);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ g2int pngunpack(unsigned char *cpack,g2int len,g2int *idrstmpl,g2int ndpts,
|
|||||||
ctemp=(unsigned char *)calloc(ndpts*4,1);
|
ctemp=(unsigned char *)calloc(ndpts*4,1);
|
||||||
if ( ifld == 0 || ctemp == 0) {
|
if ( ifld == 0 || ctemp == 0) {
|
||||||
fprintf(stderr,"Could not allocate space in jpcunpack.\n Data field NOT upacked.\n");
|
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);
|
return(1);
|
||||||
}
|
}
|
||||||
dec_png(cpack,&width,&height,ctemp);
|
dec_png(cpack,&width,&height,ctemp);
|
||||||
|
|||||||
Reference in New Issue
Block a user