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);
|
if (stars) free(stars);
|
||||||
stars = (STAR*)calloc(sizeof(STAR), (long unsigned int)nstars);
|
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++) {
|
for (i=0; i<nstars; i++) {
|
||||||
replace_star(i);
|
replace_star(i);
|
||||||
|
@ -719,7 +724,12 @@ tImageJPG *LoadJPG(const char *filename) {
|
||||||
jpeg_create_decompress(&cinfo);
|
jpeg_create_decompress(&cinfo);
|
||||||
jpeg_stdio_src(&cinfo, pFile);
|
jpeg_stdio_src(&cinfo, pFile);
|
||||||
pImageData = (tImageJPG*)malloc(sizeof(tImageJPG));
|
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);
|
DecodeJPG(&cinfo, pImageData);
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
|
|
@ -110,11 +110,11 @@ static ImageRec *ImageOpen(const char *fileName){
|
||||||
}
|
}
|
||||||
image = (ImageRec *)malloc(sizeof(ImageRec));
|
image = (ImageRec *)malloc(sizeof(ImageRec));
|
||||||
if (image == NULL) {
|
if (image == NULL) {
|
||||||
fprintf(stderr, "Out of memory!\n");
|
goto error;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
if ((image->file = fopen(fileName, "rb")) == NULL) {
|
if ((image->file = fopen(fileName, "rb")) == NULL) {
|
||||||
perror(fileName);
|
perror(fileName);
|
||||||
|
free(image);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
fread(image, 1, 12, image->file);
|
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->tmpG = (unsigned char *)malloc(image->xsize*256);
|
||||||
image->tmpB = (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) {
|
if (image->tmp == NULL || image->tmpR == NULL || image->tmpG == NULL ||image->tmpB == NULL) {
|
||||||
fprintf(stderr, "Out of memory!\n");
|
goto error;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((image->type & 0xFF00) == 0x0100) {
|
if ((image->type & 0xFF00) == 0x0100) {
|
||||||
|
@ -136,8 +135,7 @@ static ImageRec *ImageOpen(const char *fileName){
|
||||||
image->rowStart = (unsigned *)malloc(x);
|
image->rowStart = (unsigned *)malloc(x);
|
||||||
image->rowSize = (int *)malloc(x);
|
image->rowSize = (int *)malloc(x);
|
||||||
if (image->rowStart == NULL || image->rowSize == NULL) {
|
if (image->rowStart == NULL || image->rowSize == NULL) {
|
||||||
fprintf(stderr, "Out of memory!\n");
|
goto error;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
image->rleEnd = 512 + (2 * x);
|
image->rleEnd = 512 + (2 * x);
|
||||||
fseek(image->file, 512, SEEK_SET);
|
fseek(image->file, 512, SEEK_SET);
|
||||||
|
@ -149,6 +147,19 @@ static ImageRec *ImageOpen(const char *fileName){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return image;
|
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) {
|
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));
|
gbuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char));
|
||||||
bbuf = (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));
|
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;
|
lptr = base;
|
||||||
for(y=0; y<image->ysize; y++) {
|
for(y=0; y<image->ysize; y++) {
|
||||||
if(image->zsize>=4) {
|
if(image->zsize>=4) {
|
||||||
|
@ -365,6 +376,14 @@ unsigned * read_rgb_texture(const char *name, int *width, int *height, int *comp
|
||||||
free(bbuf);
|
free(bbuf);
|
||||||
free(abuf);
|
free(abuf);
|
||||||
return (unsigned *) base;
|
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$";
|
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!)
|
// Allocate the structure that will hold our eventual image data (must free it!)
|
||||||
pImageData = (tImageTGA*)malloc(sizeof(tImageTGA));
|
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
|
// Read in the length in bytes from the header to the pixel data
|
||||||
fread(&length, sizeof(byte), 1, pFile);
|
fread(&length, sizeof(byte), 1, pFile);
|
||||||
|
|
|
@ -7235,3 +7235,20 @@ David 13 July 2007
|
||||||
http_curl.C
|
http_curl.C
|
||||||
html/inc
|
html/inc
|
||||||
stats_sites.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;
|
int retval;
|
||||||
double size;
|
double size;
|
||||||
|
|
||||||
// scan the output files, check if missing or too big
|
// scan the output files, check if missing or too big.
|
||||||
// Don't bother doing this if result was aborted via GUI
|
// Don't bother doing this if result was aborted via GUI or by project
|
||||||
|
//
|
||||||
if (rp->exit_status != ERR_ABORTED_VIA_GUI) {
|
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++) {
|
for (i=0; i<rp->output_files.size(); i++) {
|
||||||
FILE_REF& fref = rp->output_files[i];
|
FILE_REF& fref = rp->output_files[i];
|
||||||
fip = fref.file_info;
|
fip = fref.file_info;
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
|
#include "file_names.h"
|
||||||
#include "client_msgs.h"
|
#include "client_msgs.h"
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
#include "http_curl.h"
|
#include "http_curl.h"
|
||||||
|
|
Loading…
Reference in New Issue