master c4e17d50f99: Prevent double closure of canvas image file descriptors and fix Android build

Po Lu via Mailing list for Emacs changes <[email protected]>
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: master
commit c4e17d50f99d60224ae5ba82b59404718f83bf6d
Author: Po Lu <[email protected]>
Commit: Po Lu <[email protected]>

    Prevent double closure of canvas image file descriptors and fix Android build
    
    * src/image.c (canvas_apply_data): Locate and open binary image
    files with `image_find_image_fd' and do not close it after it is
    read by slurp_file, which does so itself.
---
 src/image.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/src/image.c b/src/image.c
index 5683e8ed229..531b597988e 100644
--- a/src/image.c
+++ b/src/image.c
@@ -5615,16 +5615,9 @@ canvas_apply_data (struct canvas *c, struct image_keyword *fmt)
     }
   else if (STRINGP (file)) /* Binary file with ARGB32 data.  */
     {
-      Lisp_Object found = image_find_image_file (file);
-      if (NILP (found))
-	{
-	  image_error ("Cannot find image :file to load for canvas %s", file);
-	  return;
-	}
-
-      Lisp_Object encoded = ENCODE_FILE (found);
-      int fd = emacs_open (SSDATA (encoded), O_RDONLY | O_BINARY, 0);
-      if (fd < 0)
+      image_fd fd;
+      Lisp_Object found = image_find_image_fd (file, &fd);
+      if (!STRINGP (found))
 	{
 	  image_error ("Cannot open image :file for canvas %s", file);
 	  return;
@@ -5632,7 +5625,6 @@ canvas_apply_data (struct canvas *c, struct image_keyword *fmt)
 
       ptrdiff_t nbytes;
       uint32_t *buf = (uint32_t *) slurp_file (fd, &nbytes);
-      emacs_close (fd);
       if (!buf)
 	{
 	  image_error ("Cannot read image :file for canvas %s", file);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.