summaryrefslogtreecommitdiff
path: root/src/interface.c
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2012-08-08 16:28:34 (GMT)
committer jacksonmj <mj-pt@jacksonmj.co.uk>2012-08-13 23:05:48 (GMT)
commit3c78cce7a56c91b7c4db8526f988101a5e1e2b2c (patch)
tree2d47dfcd85b085e62326ad9df8b31b320e979442 /src/interface.c
parent8ec0f41fb143a6bda08d078232f3d70b36328dc4 (diff)
downloadpowder-3c78cce7a56c91b7c4db8526f988101a5e1e2b2c.zip
powder-3c78cce7a56c91b7c4db8526f988101a5e1e2b2c.tar.gz
fix many crashes when out of memory
Diffstat (limited to 'src/interface.c')
-rw-r--r--src/interface.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/interface.c b/src/interface.c
index 0184f03..e2b1d0b 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -2279,6 +2279,8 @@ void menu_ui(pixel *vid_buf, int i, int *sl, int *sr)
{
int b=1,bq,mx,my,h,x,y,n=0,height,width,sy,rows=0;
pixel *old_vid=(pixel *)calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
+ if (!old_vid)
+ return;
fillrect(vid_buf, -1, -1, XRES+1, YRES+MENUSIZE, 0, 0, 0, 192);
memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);
@@ -3306,6 +3308,8 @@ int search_ui(pixel *vid_buf)
void *thumb, *data;
int thlen, dlen;
+ if (!v_buf)
+ return 0;
memset(v_buf, 0, ((YRES+MENUSIZE)*(XRES+BARSIZE))*PIXELSIZE);
memset(img_http, 0, sizeof(img_http));
@@ -4102,6 +4106,8 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
ui_copytext ctb;
pixel *old_vid=(pixel *)calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
+ if (!old_vid || !info)
+ return 0;
fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
viewcountbuffer[0] = 0;
@@ -5448,6 +5454,8 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) {
ed.multiline = 0;
ed.cursor = 0;
//fillrect(vid_buf, -1, -1, XRES, 220, 0, 0, 0, 190);
+ if (!old_buf)
+ return NULL;
memcpy(old_buf,vid_buf,(XRES+BARSIZE)*YRES*PIXELSIZE);
fillrect(old_buf, -1, -1, XRES+BARSIZE, 220, 0, 0, 0, 190);
@@ -5663,6 +5671,8 @@ unsigned int decorations_ui(pixel *vid_buf,int *bsx,int *bsy, unsigned int saved
box_B.cursor = 0;
+ if (!old_buf)
+ return PIXRGB(currR,currG,currB);
memcpy(old_buf,vid_buf,(XRES+BARSIZE)*YRES*PIXELSIZE);
while (!sdl_poll())
{
@@ -6423,6 +6433,8 @@ void catalogue_ui(pixel * vid_buf)
ui_edit ed;
vid_buf2 = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
+ if (!vid_buf2)
+ return;
ed.w = xsize-16-4;
ed.x = x0+11;
@@ -6811,6 +6823,8 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
part_vbuf = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); //Extra video buffer
part_vbuf_store = part_vbuf;
+ if (!o_vid_buf || !part_vbuf || !part_vbuf_store)
+ return;
while (!sdl_poll())
{
b = mouse_get_state(&mx, &my);