Commit d10e9221 authored by derf's avatar derf Committed by GitHub
Browse files

Merge pull request #289 from stoeckmann/memory-leak

Fixed memory leak on file name collision.
parents b6bc4ef7 08dbe8e2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -169,9 +169,11 @@ char *feh_unique_filename(char *path, char *basename)
	ppid = getpid();
	snprintf(cppid, sizeof(cppid), "%06ld", (long) ppid);

	tmpname = NULL;
	/* make sure file doesn't exist */
	do {
		snprintf(num, sizeof(num), "%06ld", i++);
		free(tmpname);
		tmpname = estrjoin("", path, "feh_", cppid, "_", num, "_", basename, NULL);
	}
	while (stat(tmpname, &st) == 0);