mirror of https://github.com/BOINC/boinc.git
- API: some out-of-mem checks
svn path=/trunk/boinc/; revision=13151
This commit is contained in:
parent
6285969149
commit
905910f806
12
api/gutil.C
12
api/gutil.C
|
@ -486,6 +486,11 @@ void STARFIELD::build_stars(int sz, float sp) {
|
|||
|
||||
if (stars) free(stars);
|
||||
stars = (STAR*)calloc(sizeof(STAR), (long unsigned int)nstars);
|
||||
if (!stars) {
|
||||
fprintf(stderr, "out of mem in STARFIELD::build_stars");
|
||||
sz = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
for (i=0; i<nstars; i++) {
|
||||
replace_star(i);
|
||||
|
@ -719,7 +724,12 @@ tImageJPG *LoadJPG(const char *filename) {
|
|||
jpeg_create_decompress(&cinfo);
|
||||
jpeg_stdio_src(&cinfo, pFile);
|
||||
pImageData = (tImageJPG*)malloc(sizeof(tImageJPG));
|
||||
if (!pImageData) return 0;
|
||||
if (!pImageData) {
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
fclose(pFile);
|
||||
fprintf(stderr, "out of mem in LoadJPG");
|
||||
return 0;
|
||||
}
|
||||
DecodeJPG(&cinfo, pImageData);
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
fclose(pFile);
|
||||
|
|
|
@ -110,11 +110,11 @@ static ImageRec *ImageOpen(const char *fileName){
|
|||
}
|
||||
image = (ImageRec *)malloc(sizeof(ImageRec));
|
||||
if (image == NULL) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
return NULL;
|
||||
goto error;
|
||||
}
|
||||
if ((image->file = fopen(fileName, "rb")) == NULL) {
|
||||
perror(fileName);
|
||||
free(image);
|
||||
return NULL;
|
||||
}
|
||||
fread(image, 1, 12, image->file);
|
||||
|
@ -127,8 +127,7 @@ static ImageRec *ImageOpen(const char *fileName){
|
|||
image->tmpG = (unsigned char *)malloc(image->xsize*256);
|
||||
image->tmpB = (unsigned char *)malloc(image->xsize*256);
|
||||
if (image->tmp == NULL || image->tmpR == NULL || image->tmpG == NULL ||image->tmpB == NULL) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
return NULL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((image->type & 0xFF00) == 0x0100) {
|
||||
|
@ -136,8 +135,7 @@ static ImageRec *ImageOpen(const char *fileName){
|
|||
image->rowStart = (unsigned *)malloc(x);
|
||||
image->rowSize = (int *)malloc(x);
|
||||
if (image->rowStart == NULL || image->rowSize == NULL) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
return NULL;
|
||||
goto error;
|
||||
}
|
||||
image->rleEnd = 512 + (2 * x);
|
||||
fseek(image->file, 512, SEEK_SET);
|
||||
|
@ -149,6 +147,19 @@ static ImageRec *ImageOpen(const char *fileName){
|
|||
}
|
||||
}
|
||||
return image;
|
||||
error:
|
||||
if (image) {
|
||||
if (image->rowSize) free(image->rowSize);
|
||||
if (image->rowStart) free(image->rowStart);
|
||||
if (image->tmpB) free(image->tmpB);
|
||||
if (image->tmpG) free(image->tmpG);
|
||||
if (image->tmpR)free(image->tmpR);
|
||||
if (image->tmp) free(image->tmp);
|
||||
if (image->file) fclose(image->file);
|
||||
free(image);
|
||||
}
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void ImageClose(ImageRec *image) {
|
||||
|
@ -332,7 +343,7 @@ unsigned * read_rgb_texture(const char *name, int *width, int *height, int *comp
|
|||
gbuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char));
|
||||
bbuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char));
|
||||
abuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char));
|
||||
if(!base || !rbuf || !gbuf || !bbuf) return NULL;
|
||||
if(!base || !rbuf || !gbuf || !bbuf) goto error;
|
||||
lptr = base;
|
||||
for(y=0; y<image->ysize; y++) {
|
||||
if(image->zsize>=4) {
|
||||
|
@ -365,6 +376,14 @@ unsigned * read_rgb_texture(const char *name, int *width, int *height, int *comp
|
|||
free(bbuf);
|
||||
free(abuf);
|
||||
return (unsigned *) base;
|
||||
error:
|
||||
ImageClose(image);
|
||||
if (abuf) free(abuf);
|
||||
if (bbuf) free(bbuf);
|
||||
if (bbuf) free(gbuf);
|
||||
if (bbuf) free(rbuf);
|
||||
if (base) free(base);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *BOINC_RCSID_97d4f29d84="$Id$";
|
||||
|
|
|
@ -33,6 +33,11 @@ tImageTGA *LoadTGA(const char *filename)
|
|||
|
||||
// Allocate the structure that will hold our eventual image data (must free it!)
|
||||
pImageData = (tImageTGA*)malloc(sizeof(tImageTGA));
|
||||
if (!pImageData) {
|
||||
fprintf(stderr, "out of mem in LoadTGA");
|
||||
fclose(pFile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Read in the length in bytes from the header to the pixel data
|
||||
fread(&length, sizeof(byte), 1, pFile);
|
||||
|
|
|
@ -7235,3 +7235,20 @@ David 13 July 2007
|
|||
http_curl.C
|
||||
html/inc
|
||||
stats_sites.inc
|
||||
|
||||
David 13 July 2007
|
||||
- API: fix unlikely memory leaks in graphics
|
||||
|
||||
api/
|
||||
texture.C
|
||||
|
||||
David 13 July 2007
|
||||
- API: some out-of-mem checks
|
||||
|
||||
api/
|
||||
gutil.C
|
||||
texture.C
|
||||
tgalib.C
|
||||
client/
|
||||
cs_apps.C
|
||||
http_curl.C
|
||||
|
|
|
@ -109,10 +109,14 @@ int CLIENT_STATE::app_finished(ACTIVE_TASK& at) {
|
|||
int retval;
|
||||
double size;
|
||||
|
||||
// scan the output files, check if missing or too big
|
||||
// Don't bother doing this if result was aborted via GUI
|
||||
|
||||
if (rp->exit_status != ERR_ABORTED_VIA_GUI) {
|
||||
// scan the output files, check if missing or too big.
|
||||
// Don't bother doing this if result was aborted via GUI or by project
|
||||
//
|
||||
switch (rp->exit_status) {
|
||||
case ERR_ABORTED_VIA_GUI:
|
||||
case ERR_ABORTED_BY_PROJECT:
|
||||
break;
|
||||
default:
|
||||
for (i=0; i<rp->output_files.size(); i++) {
|
||||
FILE_REF& fref = rp->output_files[i];
|
||||
fip = fref.file_info;
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "util.h"
|
||||
|
||||
#include "network.h"
|
||||
#include "file_names.h"
|
||||
#include "client_msgs.h"
|
||||
#include "base64.h"
|
||||
#include "http_curl.h"
|
||||
|
|
Loading…
Reference in New Issue