Просмотр исходного кода

KWSys: SystemInformation: Add missing EOF check when reading /proc/cpuinfo

Backport KWSys upstream commit `6e847d08b` (SystemInformation: Add
missing EOF check when reading /proc/cpuinfo, 2024-10-23) to the
CMake 3.31 release branch.
Brad King 1 год назад
Родитель
Сommit
51ed0eba18
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      Source/kwsys/SystemInformation.cxx

+ 3 - 2
Source/kwsys/SystemInformation.cxx

@@ -3405,8 +3405,9 @@ bool SystemInformationImplementation::RetrieveInformationFromCpuInfoFile()
   }
 
   size_t fileSize = 0;
-  while (!feof(fd)) {
-    buffer += static_cast<char>(fgetc(fd));
+  int fc;
+  while ((fc = fgetc(fd)) != EOF) {
+    buffer += static_cast<char>(fc);
     fileSize++;
   }
   fclose(fd);