summaryrefslogtreecommitdiff
path: root/src/interface.c
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-09-10 12:33:24 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-09-10 12:33:24 (GMT)
commit49a164b7ba69db5f8e50ee2576d0101a5304d860 (patch)
tree7111e313a0bb0e1b2ebf8afeb069a8053a5d1d1e /src/interface.c
parent8084ae388effc43a833afef016440360013b9141 (diff)
downloadpowder-49a164b7ba69db5f8e50ee2576d0101a5304d860.zip
powder-49a164b7ba69db5f8e50ee2576d0101a5304d860.tar.gz
Fix various memory leaks, as noted by Merkil/cppcheck
Diffstat (limited to 'src/interface.c')
-rw-r--r--src/interface.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/interface.c b/src/interface.c
index 3370883..379da11 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -5337,10 +5337,12 @@ int save_filename_ui(pixel *vid_buf)
int x0=(XRES+BARSIZE-xsize)/2,y0=(YRES+MENUSIZE-ysize)/2,b=1,bq,mx,my;
int idtxtwidth, nd=0, imgw, imgh, save_size;
void *save_data;
+ char *savefname = NULL;
+ char *filename = NULL;
pixel *old_vid=(pixel *)calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
pixel *save_tmp;
pixel *save_data_image;
- pixel *save = calloc((XRES/3)*(YRES/3), PIXELSIZE);
+ pixel *save = NULL;//calloc((XRES/3)*(YRES/3), PIXELSIZE);
ui_edit ed;
save_data = build_save(&save_size, 0, 0, XRES, YRES, bmap, fvx, fvy, signs, parts);
@@ -5412,8 +5414,8 @@ int save_filename_ui(pixel *vid_buf)
if(b && !bq)
{
FILE *f = NULL;
- char *savefname = malloc(strlen(ed.str)+5);
- char *filename = malloc(strlen(LOCAL_SAVE_DIR)+strlen(PATH_SEP)+strlen(ed.str)+5);
+ savefname = malloc(strlen(ed.str)+5);
+ filename = malloc(strlen(LOCAL_SAVE_DIR)+strlen(PATH_SEP)+strlen(ed.str)+5);
sprintf(filename, "%s%s%s.cps", LOCAL_SAVE_DIR, PATH_SEP, ed.str);
sprintf(savefname, "%s.cps", ed.str);
@@ -5446,6 +5448,7 @@ int save_filename_ui(pixel *vid_buf)
}
}
fclose(f);
+
}
}
@@ -5468,6 +5471,8 @@ savefin:
free(save_data);
free(old_vid);
free(save);
+ if(filename) free(filename);
+ if(savefname) free(savefname);
return 0;
}