[Support] Properly zero initialize CPU set when querying affinity (#142924)
This commit resolves a potential issue of working with uninitialized memory when querying the CPU's affinity. The man page of `sched_getaffinity` does not guarantee that the memory will be fully overwritten, so this change should ensure that issues are avoided.
This commit is contained in:
parent
7d4464599f
commit
052d5889f8
@ -318,6 +318,7 @@ static int computeHostNumHardwareThreads() {
|
||||
return CPU_COUNT(&mask);
|
||||
#elif defined(__linux__)
|
||||
cpu_set_t Set;
|
||||
CPU_ZERO(&Set);
|
||||
if (sched_getaffinity(0, sizeof(Set), &Set) == 0)
|
||||
return CPU_COUNT(&Set);
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user