diff options
author | Daniel Friesel <derf@finalrewind.org> | 2017-09-05 18:14:56 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2017-09-05 18:14:56 +0200 |
commit | 72cafcccdeabe56809d26e0afac5de6d3c331150 (patch) | |
tree | ba8846dbaa025b3d033b40c2ed4ad744c26ecc22 /src/imlib.c | |
parent | d77e4f0a32866f164556e9de8faec3923c7b314e (diff) |
Work around ImageMagick bug when converting to file descriptors (#323)
Diffstat (limited to 'src/imlib.c')
-rw-r--r-- | src/imlib.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/imlib.c b/src/imlib.c index cdc4fe7..71b0a81 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -283,7 +283,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file) static char *feh_magick_load_image(char *filename) { - char argv_fd[12]; + char *argv_fn; char *basename; char *tmpname; char *sfn; @@ -310,10 +310,17 @@ static char *feh_magick_load_image(char *filename) fd = mkstemp(sfn); - if (fd == -1) + if (fd == -1) { + free(sfn); return NULL; + } - snprintf(argv_fd, sizeof(argv_fd), "png:fd:%d", fd); + /* + * We could use png:fd:(whatever mkstemp returned) as target filename + * for convert, but this seems to be broken in some ImageMagick versions. + * So we resort to png:(sfn) instead. + */ + argv_fn = estrjoin(":", "png", sfn, NULL); if ((childpid = fork()) < 0) { weprintf("%s: Can't load with imagemagick. Fork failed:", filename); @@ -336,7 +343,7 @@ static char *feh_magick_load_image(char *filename) */ setpgid(0, 0); - execlp("convert", "convert", filename, argv_fd, NULL); + execlp("convert", "convert", filename, argv_fn, NULL); _exit(1); } else { @@ -369,6 +376,7 @@ static char *feh_magick_load_image(char *filename) childpid = 0; } + free(argv_fn); return sfn; } |