From 16e66419ad20692e9637b09e56db3cfa10589da1 Mon Sep 17 00:00:00 2001 From: Gymee <8039110+Gymee@user.noreply.gitee.com> Date: Sun, 20 Sep 2020 12:36:53 +0800 Subject: [PATCH] add return value checking for fseek before calling ftell --- apphilogcat/hiview_applogcat.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apphilogcat/hiview_applogcat.c b/apphilogcat/hiview_applogcat.c index 69d0348..58b844d 100755 --- a/apphilogcat/hiview_applogcat.c +++ b/apphilogcat/hiview_applogcat.c @@ -43,10 +43,13 @@ static int FileSize(const char *filename) if (!fp) { return -1; } - fseek(fp, 0L, SEEK_END); - int size = ftell(fp); - fclose(fp); + int size = 0; + int ret = fseek(fp, 0L, SEEK_END); + if (ret == 0) { + size = ftell(fp); + } + fclose(fp); return size; } -- Gitee