This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository legacy-imlib2.

View the commit online.

commit 592bea92086fe9155a01b70f3470e676889a6540
Author: Kim Woelders <[email protected]>
AuthorDate: Fri Feb 3 10:11:11 2023 +0100

    Loaders, savers: Handle EINTR during fopen()
    
    Fixes potential error when saving to pipe in the presence of signals
    (if nothing else).
    
    https://git.enlightenment.org/old/legacy-imlib2/issues/5
---
 src/lib/file.c  | 19 +++++++++++++++++++
 src/lib/file.h  |  3 +++
 src/lib/image.c |  4 ++--
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/lib/file.c b/src/lib/file.c
index 97ab0ea..32e233a 100644
--- a/src/lib/file.c
+++ b/src/lib/file.c
@@ -320,3 +320,22 @@ __imlib_ItemInList(char **list, int size, char *item)
      }
    return 0;
 }
+
+#include <errno.h>
+
+FILE               *
+__imlib_FileOpen(const char *path, const char *mode)
+{
+   FILE               *fp;
+
+   for (;;)
+     {
+        fp = fopen(path, mode);
+        if (fp)
+           break;
+        if (errno != EINTR)
+           break;
+     }
+
+   return fp;
+}
diff --git a/src/lib/file.h b/src/lib/file.h
index ae7ce86..013ddc2 100644
--- a/src/lib/file.h
+++ b/src/lib/file.h
@@ -48,4 +48,7 @@ char              **__imlib_PathToLoaders(void);
 char              **__imlib_ModulesList(char **path, int *num_ret);
 char               *__imlib_ModuleFind(char **path, const char *name);
 
+#include <stdio.h>
+FILE               *__imlib_FileOpen(const char *path, const char *mode);
+
 #endif
diff --git a/src/lib/image.c b/src/lib/image.c
index 801d100..5f81236 100644
--- a/src/lib/image.c
+++ b/src/lib/image.c
@@ -104,7 +104,7 @@ __imlib_FileContextOpen(ImlibImageFileInfo * fi, FILE * fp,
      }
    else
      {
-        fi->fp = fopen(fi->name, "rb");
+        fi->fp = __imlib_FileOpen(fi->name, "rb");
         if (!fi->fp)
            return -1;
      }
@@ -884,7 +884,7 @@ __imlib_SaveImage(ImlibImage * im, const char *file, ImlibLoadArgs * ila)
         return;
      }
 
-   fp = fopen(file, "wb");
+   fp = __imlib_FileOpen(file, "wb");
    if (!fp)
      {
         ila->err = errno;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to