process.totalSystemMemory: Avoid overflow on Linux when totalram is a 32-bit usize

Fixes #25038
This commit is contained in:
Ryan Liptak
2025-08-27 22:16:21 -07:00
committed by Alex Rønne Petersen
parent cb9821a827
commit cbc3c0dc59

View File

@@ -1753,7 +1753,8 @@ pub fn totalSystemMemory() TotalSystemMemoryError!u64 {
if (std.os.linux.E.init(result) != .SUCCESS) {
return error.UnknownTotalSystemMemory;
}
return info.totalram * info.mem_unit;
// Promote to u64 to avoid overflow on systems where info.totalram is a 32-bit usize
return @as(u64, info.totalram) * info.mem_unit;
},
.freebsd => {
var physmem: c_ulong = undefined;