use physical memory in kib to avoid overflow of size_t (issue #1010)

This commit is contained in:
daanx 2025-02-11 09:12:29 -08:00
parent 78dd3f0e38
commit ec4aa62b65
4 changed files with 18 additions and 18 deletions

View file

@ -143,7 +143,7 @@ void _mi_prim_mem_init( mi_os_mem_config_t* config )
#if defined(_SC_PHYS_PAGES)
long pphys = sysconf(_SC_PHYS_PAGES);
if (pphys > 0 && (size_t)pphys < (SIZE_MAX/(size_t)psize)) {
config->physical_memory = (size_t)pphys * (size_t)psize;
config->physical_memory_in_kib = (size_t)pphys * ((size_t)psize / MI_KiB);
}
#endif
}