File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed
Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -142,8 +142,9 @@ void _mi_prim_mem_init( mi_os_mem_config_t* config )
142142 config -> alloc_granularity = (size_t )psize ;
143143 #if defined(_SC_PHYS_PAGES )
144144 long pphys = sysconf (_SC_PHYS_PAGES );
145- if (pphys > 0 && (size_t )pphys < (SIZE_MAX /(size_t )psize )) {
146- config -> physical_memory_in_kib = (size_t )pphys * ((size_t )psize / MI_KiB );
145+ const size_t psize_in_kib = (size_t )psize / MI_KiB ;
146+ if (psize_in_kib > 0 && pphys > 0 && (size_t )pphys <= (SIZE_MAX /psize_in_kib )) {
147+ config -> physical_memory_in_kib = (size_t )pphys * psize_in_kib ;
147148 }
148149 #endif
149150 }
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ void _mi_prim_mem_init( mi_os_mem_config_t* config )
154154 if (pGetPhysicallyInstalledSystemMemory != NULL ) {
155155 ULONGLONG memInKiB = 0 ;
156156 if ((* pGetPhysicallyInstalledSystemMemory )(& memInKiB )) {
157- if (memInKiB > 0 && memInKiB < ( SIZE_MAX / MI_KiB ) ) {
157+ if (memInKiB > 0 && memInKiB <= SIZE_MAX ) {
158158 config -> physical_memory_in_kib = memInKiB ;
159159 }
160160 }
You can’t perform that action at this time.
0 commit comments