exactness: handle case where eet_data_image_write() fails
authorStefan Schmidt <s.schmidt@samsung.com>
Fri, 17 Apr 2020 12:06:57 +0000 (14:06 +0200)
committerJongmin Lee <jm105.lee@samsung.com>
Mon, 20 Apr 2020 21:11:28 +0000 (06:11 +0900)
We never checked how many bytes had been written. Check on return and
propagate error upwards to caller.

CID: 1419856

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D11724

src/bin/exactness/common.c

index 8142d09..d62d8fd 100644 (file)
@@ -339,6 +339,9 @@ exactness_unit_file_write(Exactness_Unit *unit, const char *filename)
    Exactness_Image *ex_img;
    Eet_File *file;
    int i = 1;
+   int bytes;
+   Eina_Bool ret = EINA_TRUE;
+
    eet_init();
    file = eet_open(filename, EET_FILE_MODE_WRITE);
    eet_data_write(file, _unit_desc_make(), "cache", unit, EINA_TRUE);
@@ -346,13 +349,17 @@ exactness_unit_file_write(Exactness_Unit *unit, const char *filename)
      {
         char entry[32];
         sprintf(entry, "images/%d", i++);
-        eet_data_image_write(file, entry,
-              ex_img->pixels, ex_img->w, ex_img->h, 0xFF,
-              0, 100, EET_IMAGE_LOSSLESS);
+        bytes = eet_data_image_write(file, entry, ex_img->pixels, ex_img->w, ex_img->h, 0xFF,
+                                     0, 100, EET_IMAGE_LOSSLESS);
+        if (bytes == 0)
+          {
+             ret = EINA_FALSE;
+             break;
+         }
      }
    eet_close(file);
    eet_shutdown();
-   return EINA_TRUE;
+   return ret;
 }
 
 Eina_Bool