summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <hg@njw.me.uk>2011-07-16 15:14:16 +0100
committerNick White <hg@njw.me.uk>2011-07-16 15:14:16 +0100
commit5e8f9f92a2bc1eb1665fdb902afe1111c864b7b5 (patch)
tree53ff8400f33e759c62a2f980e9c581a2eda2bd9d
parent4d6350f4adef68ddb9aeb8a19c81ff7bbbffba98 (diff)
Tighten memory usage
-rw-r--r--util.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/util.c b/util.c
index 8d0fa8c..1017b1b 100644
--- a/util.c
+++ b/util.c
@@ -71,14 +71,13 @@ int gettofile(char *url, char *savepath) {
}
if((f = fopen(savepath, "w")) == NULL) {
fprintf(stderr, "Could not create file %s\n", savepath);
- return 1;
+ free(buf); return 1;
}
for(i=0; i < l; i+=512)
if(!fwrite(buf+i, l-i > 512 ? 512 : l-i, 1, f)) {
fprintf(stderr, "Error writing file %s\n", savepath);
- free(buf); fclose(f);
- return 1;
+ free(buf); fclose(f); return 1;
}
free(buf);