From: jiyong.min Date: Tue, 29 Jan 2019 00:28:04 +0000 (+0900) Subject: Add to check the return of fread() X-Git-Tag: submit/tizen/20190131.041045~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f97a101efe6fa864af3ccd29874165e28f08c792;p=platform%2Fcore%2Fapi%2Fmetadata-editor.git Add to check the return of fread() - If an error occurs, the return value is a short item count. Change-Id: I3acb7494ff53f56243ae239b6c1371eb5537478f --- diff --git a/src/metadata_editor.cpp b/src/metadata_editor.cpp index 7d8379a..61034fd 100755 --- a/src/metadata_editor.cpp +++ b/src/metadata_editor.cpp @@ -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) {