[nnc] Fix unchecked ferror on file descriptor after reading file (#1746)
authorПавел Ильютченко/AI Tools Lab /SRR/Assistant Engineer/삼성전자 <p.iliutchenk@partner.samsung.com>
Tue, 9 Oct 2018 12:42:20 +0000 (15:42 +0300)
committerРоман Михайлович Русяев/AI Tools Lab /SRR/Staff Engineer/삼성전자 <r.rusyaev@samsung.com>
Tue, 9 Oct 2018 12:42:20 +0000 (15:42 +0300)
* May occur error while reading which is skipped without checking ferror

Signed-off-by: Pavel Iliutchenko <p.iliutchenk@partner.samsung.com>
contrib/nnc/utils/def2src.cpp

index 3728091..3e9e5b6 100644 (file)
@@ -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] << ", ";