billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/ephoto.git/commit/?id=37542da610c264600bd420c904109bb28d8a802f

commit 37542da610c264600bd420c904109bb28d8a802f
Author: Boris Faure <[email protected]>
Date:   Sun Sep 25 17:56:45 2016 +0200

    check filesystem operations
---
 src/bin/ephoto_file.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/bin/ephoto_file.c b/src/bin/ephoto_file.c
index e80445e..a518d7f 100644
--- a/src/bin/ephoto_file.c
+++ b/src/bin/ephoto_file.c
@@ -962,6 +962,7 @@ _prompt_upload_apply(void *data, Evas_Object *obj 
EINA_UNUSED,
    FILE *f;
    unsigned char *fdata;
    int fsize;
+   int res;
 
    evas_object_del(ppopup);
    popup = _processing(ephoto, _("Upload Image"),
@@ -969,12 +970,17 @@ _prompt_upload_apply(void *data, Evas_Object *obj 
EINA_UNUSED,
    evas_object_show(popup);
 
    f = fopen(entry->path, "rb");
-   fseek(f, 0, SEEK_END);
+   if (!f) CRIT("unable to open '%s': %s", entry->path, strerror(errno));
+   res = fseek(f, 0, SEEK_END);
+   if (!res) CRIT("fseek() failed on file '%s': %s", entry->path, 
strerror(errno));
    fsize = ftell(f);
+   if (fsize == -1) CRIT("ftell() failed on file '%s': %s", entry->path, 
strerror(errno));
    rewind(f);
    fdata = malloc(fsize);
-   fread(fdata, fsize, 1, f);
-   fclose(f);
+   res = fread(fdata, fsize, 1, f);
+   if (res < 1) CRIT("fread() failed on file '%s': %s", entry->path, 
strerror(errno));
+   res = fclose(f);
+   if (!res) CRIT("fclose() failed on file '%s': %s", entry->path, 
strerror(errno));
 
    snprintf(buf, PATH_MAX, "image=%s", fdata);
 

-- 


Reply via email to