From 86510aa295308214c0e4562e7ecd23399d00ab3a Mon Sep 17 00:00:00 2001 From: jackyu2020 <64533877+jackyu2020@users.noreply.github.com> Date: Sun, 3 May 2020 09:49:57 +0800 Subject: [PATCH] check the return value of fscanf (#2218) Signed-off-by: e --- core/src/metrics/SystemInfo.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/metrics/SystemInfo.cpp b/core/src/metrics/SystemInfo.cpp index 3ba70a245f..711c7cb885 100644 --- a/core/src/metrics/SystemInfo.cpp +++ b/core/src/metrics/SystemInfo.cpp @@ -318,8 +318,9 @@ SystemInfo::CPUTemperature() { return result; } float temp; - fscanf(file, "%f", &temp); - result.push_back(temp / 1000); + if (fscanf(file, "%f", &temp) != -1) { + result.push_back(temp / 1000); + } } } }