Skip to content

Commit

Permalink
Merge pull request #47 from cakebaker/free_fix_subtract_with_overflow
Browse files Browse the repository at this point in the history
free: prevent subtract with overflow on macOS
  • Loading branch information
sylvestre authored Apr 1, 2024
2 parents c5e7417 + b7d89f6 commit 65f933b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/uu/free/src/free.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ fn parse_meminfo() -> Result<MemInfo, Box<dyn std::error::Error>> {
available: sys.free_memory(),
shared: 0,
buffers: 0,
cached: sys.used_memory() - sys.free_memory(),
cached: sys.used_memory().saturating_sub(sys.free_memory()),
swap_total: sys.total_swap(),
swap_free: sys.free_swap(),
swap_used: sys.total_swap() - sys.free_swap(),
swap_used: sys.total_swap().saturating_sub(sys.free_swap()),
reclaimable: 0,
};

Expand Down

0 comments on commit 65f933b

Please sign in to comment.