authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-08-27 22:16:21-07:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-29 00:13:01+02:00
logcbc3c0dc594341faddb8841fb466254f2f6f3b35
treec6b1cad4c05267292e204ba62005b32e2e05f708
parentcb9821a827f972252f8c02775bd2df07435f04c6
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

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

Fixes #25038

1 files changed, 2 insertions(+), 1 deletions(-)

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