mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 20:09:04 +00:00
Prevent extremely unlikely division by zero
This commit is contained in:
@@ -545,10 +545,10 @@ pub fn getSystemLoadavg() [3]f64 {
|
||||
|
||||
const loadavg = loadavg_[0];
|
||||
const scale = @as(f64, @floatFromInt(loadavg.fscale));
|
||||
return [3]f64{
|
||||
@as(f64, @floatFromInt(loadavg.ldavg[0])) / scale,
|
||||
@as(f64, @floatFromInt(loadavg.ldavg[1])) / scale,
|
||||
@as(f64, @floatFromInt(loadavg.ldavg[2])) / scale,
|
||||
return .{
|
||||
if (scale == 0.0) 0 else @as(f64, @floatFromInt(loadavg.ldavg[0])) / scale,
|
||||
if (scale == 0.0) 0 else @as(f64, @floatFromInt(loadavg.ldavg[1])) / scale,
|
||||
if (scale == 0.0) 0 else @as(f64, @floatFromInt(loadavg.ldavg[2])) / scale,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user