summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/util.c b/util.c
index 4130188..b263f9f 100644
--- a/util.c
+++ b/util.c
@@ -99,6 +99,8 @@ int request(char *host, char *request, char *savecookie, char **body) {
}
}
+ free(buf);
+
return l;
}
@@ -163,14 +165,19 @@ int renameifjpg(char *path) {
return 1;
if(fgetc(f) == 255) {
- if((newpath = malloc(strlen(path) + 1)) == NULL)
+ if((newpath = malloc(strlen(path) + 1)) == NULL) {
+ fclose(f);
return 1;
+ }
strncpy(newpath, path, strlen(path));
c = strrchr(newpath, '.');
strncpy(c+1, "jpg\0", 4);
- if(rename(path, newpath))
+ if(rename(path, newpath)) {
+ free(newpath);
+ fclose(f);
return 1;
+ }
free(newpath);
}