From ff541c1ff97e5bb00669e5dd5c5b5f2f108fbeb0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB=20=D0=98=D0=BB=D1=8C=D1=8E?= =?utf8?q?=D1=82=D1=87=D0=B5=D0=BD=D0=BA=D0=BE/AI=20Tools=20Lab=20/SRR/Ass?= =?utf8?q?istant=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 9 Oct 2018 15:42:20 +0300 Subject: [PATCH] [nnc] Fix unchecked ferror on file descriptor after reading file (#1746) * May occur error while reading which is skipped without checking ferror Signed-off-by: Pavel Iliutchenko --- contrib/nnc/utils/def2src.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/nnc/utils/def2src.cpp b/contrib/nnc/utils/def2src.cpp index 3728091..3e9e5b6 100644 --- a/contrib/nnc/utils/def2src.cpp +++ b/contrib/nnc/utils/def2src.cpp @@ -46,7 +46,8 @@ int fileToArray(std::string &source, std::string &dest, std::string arrName) { do { char buf[1024]; bytes = fread(buf, 1, sizeof(buf), fs); - + assert(!ferror(fs) && "file read error"); + // convert line for (size_t i = 0; i < bytes; i++) { fo << "0x" << std::hex << (int)buf[i] << ", "; -- 2.7.4