]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Only set numPhysicalCores if ratio is valid 2517/head
authorPaul Bone <pbone@mozilla.com>
Tue, 2 Mar 2021 09:31:23 +0000 (20:31 +1100)
committerPaul Bone <paul@bone.id.au>
Tue, 2 Mar 2021 23:59:00 +0000 (10:59 +1100)
programs/util.c

index be048332b166b06c6e4e5b8d41954520e93a5fde..9b0405043f8016685b05a4b3d945bc05ba2ac0f1 100644 (file)
@@ -1212,11 +1212,13 @@ int UTIL_countPhysicalCores(void)
                 /* fall back on the sysconf value */
                 goto failed;
         }   }
-        if (siblings && cpu_cores) {
+        if (siblings && cpu_cores && siblings > cpu_cores) {
             ratio = siblings / cpu_cores;
         }
 
-        numPhysicalCores = numPhysicalCores / ratio;
+        if (ratio && numPhysicalCores > ratio) {
+            numPhysicalCores = numPhysicalCores / ratio;
+        }
 
 failed:
         fclose(cpuinfo);