Add to check the return of fread() 86/198686/2
authorjiyong.min <jiyong.min@samsung.com>
Tue, 29 Jan 2019 00:28:04 +0000 (09:28 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Tue, 29 Jan 2019 00:38:20 +0000 (09:38 +0900)
 - If an error occurs, the return value is a short item count.

Change-Id: I3acb7494ff53f56243ae239b6c1371eb5537478f

src/metadata_editor.cpp

index 7d8379a095a88adbe4e2f9344df8e10a5a4006de..61034fdbc24e8a5bd69ca7a65249d328f150ccdb 100755 (executable)
@@ -770,7 +770,7 @@ int __metadata_editor_get_picture_info(const char *path, void **picture, int *si
 
        //IF ok.. read file
        FILE* fin = fopen(path, "rb");
-       int file_size = 0;
+       size_t file_size = 0;
 
        if (fin) {
                while (fgetc(fin) != EOF)
@@ -781,7 +781,11 @@ int __metadata_editor_get_picture_info(const char *path, void **picture, int *si
                memset(picture_buffer, 0, file_size * sizeof(char));
                fin = fopen(path, "rb");
                if (fin) {
-                       ret = fread(picture_buffer, file_size, 1, fin);
+                       if(file_size != fread(picture_buffer, file_size, 1, fin)) {
+                               metadata_editor_error("fread error");
+                               fclose(fin);
+                               return METADATA_EDITOR_ERROR_OPERATION_FAILED;
+                       }
                        fclose(fin);
                }
                if (*picture == NULL) {