mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
process.totalSystemMemory: Avoid overflow on Linux when totalram is a 32-bit usize
Fixes #25038
This commit is contained in:
parent
2b73c28cec
commit
224fca7e0e
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user