Commit 78c50165 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

patch: url image loading: cleanup tmp files on error

parent ea00c2fc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
     * Replace autoconf by config.mk
     * patch by decklin: Use z key to randomly jump in the filelist
     * patch by muennich: Correctly set [Paused] window title in slideshow mode
     * patch by dylan: Remove temporary files if url opening fails
     * Fix problems with unexpectedly empty filelists

Tue Mar 16 07:56:36 CET 2010  Daniel Friesel <derf@chaosdorf.de>
+9 −0
Original line number Diff line number Diff line
@@ -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);