From cd245fd20da8c7272628e11dddf97db07ee70617 Mon Sep 17 00:00:00 2001 From: Tao Zhu Date: Tue, 14 Mar 2023 01:20:39 +0000 Subject: [PATCH] fix a math error --- programs/bpf_loader/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index 99de15523df0e5..91b244c4d0a816 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -299,15 +299,15 @@ fn check_loader_id(id: &Pubkey) -> bool { } fn calculate_heap_cost(heap_size: u64, heap_cost: u64, enable_rounding_fix: bool) -> u64 { - const KILOBYTE: u64 = 1024; + const KIBIBYTE: u64 = 1024; const PAGE_SIZE_KB: u64 = 32; let mut rounded_heap_size = heap_size; if enable_rounding_fix { rounded_heap_size = rounded_heap_size - .saturating_add(PAGE_SIZE_KB.saturating_sub(1).saturating_mul(KILOBYTE)); + .saturating_add(PAGE_SIZE_KB.saturating_mul(KIBIBYTE).saturating_sub(1)); } rounded_heap_size - .saturating_div(PAGE_SIZE_KB.saturating_mul(KILOBYTE)) + .saturating_div(PAGE_SIZE_KB.saturating_mul(KIBIBYTE)) .saturating_sub(1) .saturating_mul(heap_cost) }