From e1d409c3f258684f0b2bf467cc8edc98b6840e28 Mon Sep 17 00:00:00 2001 From: "jiyong.min" Date: Tue, 29 Jan 2019 09:20:07 +0900 Subject: [PATCH] Add to check the return of fseek() Change-Id: Iba167d0f8aa4ceb095f3a27202fb0ac2a0ce75b1 --- src/media_playlist.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/media_playlist.c b/src/media_playlist.c index b7bc197..5d0f87a 100755 --- a/src/media_playlist.c +++ b/src/media_playlist.c @@ -241,16 +241,24 @@ static int __media_playlist_import_item_from_file(const char* playlist_path, cha fp = fopen(playlist_path, "rb"); media_content_retvm_if(fp == NULL, MEDIA_CONTENT_ERROR_INVALID_OPERATION, "fopen fail"); - fseek(fp, 0, SEEK_END); + if (fseek(fp, 0, SEEK_END) < 0) { + media_content_stderror("fseek failed"); + fclose(fp); + return MEDIA_CONTENT_ERROR_INVALID_OPERATION; + } file_size = ftell(fp); - fseek(fp, 0 , SEEK_SET); - if (file_size == 0) { media_content_debug("file is empty."); fclose(fp); return MEDIA_CONTENT_ERROR_NONE; } + if (fseek(fp, 0, SEEK_SET) < 0) { + media_content_stderror("fseek failed"); + fclose(fp); + return MEDIA_CONTENT_ERROR_INVALID_OPERATION; + } + *item_list = calloc(current_max_size, sizeof(char*)); if (*item_list == NULL) { fclose(fp); -- 2.7.4