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-28 17:05:39+02:00
log224fca7e0e1cfe1bf27178ecb4e53d4f88fb9abf
tree6a896e02dc8412d396da2f3cb4d798e2d308cf2d
parent2b73c28cec9a5c75ab064f1ebd88b12aa64d22dd

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;