summaryrefslogtreecommitdiff
path: root/src/imlib.c
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-03-29 20:56:01 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2010-03-29 20:56:01 +0200
commit78c501656cf1ceb98675fe425cfc4cb9313dee00 (patch)
tree9f2ba8eb3d2a8baab354726945371824170026fd /src/imlib.c
parentea00c2fc6d91d71b8cf3c8408af8ca8de7c037a6 (diff)
patch: url image loading: cleanup tmp files on error
Diffstat (limited to 'src/imlib.c')
-rw-r--r--src/imlib.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/imlib.c b/src/imlib.c
index a789e1b..6c40245 100644
--- a/src/imlib.c
+++ b/src/imlib.c
@@ -310,6 +310,8 @@ char *feh_http_load_image(char *url)
hostname = feh_strip_hostname(newurl);
if (!hostname) {
weprintf("couldn't work out hostname from %s:", newurl);
+ fclose(fp);
+ unlink(tmpname);
free(tmpname);
free(newurl);
D_RETURN(4, NULL);
@@ -319,6 +321,8 @@ char *feh_http_load_image(char *url)
if (!(hptr = feh_gethostbyname(hostname))) {
weprintf("error resolving host %s:", hostname);
+ fclose(fp);
+ unlink(tmpname);
free(hostname);
free(tmpname);
free(newurl);
@@ -334,6 +338,8 @@ char *feh_http_load_image(char *url)
if ((sockno = socket(PF_INET, SOCK_STREAM, 0)) == -1) {
weprintf("error opening socket:");
+ fclose(fp);
+ unlink(tmpname);
free(tmpname);
free(hostname);
free(newurl);
@@ -341,6 +347,8 @@ char *feh_http_load_image(char *url)
}
if (connect(sockno, (struct sockaddr *) &addr, sizeof(addr)) == -1) {
weprintf("error connecting socket:");
+ fclose(fp);
+ unlink(tmpname);
free(tmpname);
free(hostname);
free(newurl);
@@ -486,6 +494,7 @@ char *feh_http_load_image(char *url)
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
weprintf("url: wget failed to load URL %s\n", url);
+ unlink(opt.wget_timestamp ? tmpname_timestamper : tmpname);
free(newurl);
free(tmpname);
D_RETURN(4, NULL);