From b55dc586bde6eadaf068fe9745147774f3c2cd38 Mon Sep 17 00:00:00 2001 From: krishvishal Date: Tue, 25 Mar 2025 10:10:15 +0530 Subject: [PATCH] change `compute_shl` implementation to handle negation with overflow --- core/vdbe/insn.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/vdbe/insn.rs b/core/vdbe/insn.rs index 1e2af1820..34c5c0005 100644 --- a/core/vdbe/insn.rs +++ b/core/vdbe/insn.rs @@ -975,7 +975,15 @@ pub fn exec_shift_left(mut lhs: &OwnedValue, mut rhs: &OwnedValue) -> OwnedValue } fn compute_shl(lhs: i64, rhs: i64) -> i64 { - compute_shr(lhs, -rhs) + if rhs == 0 { + lhs + } else if rhs >= 64 || rhs <= -64 { + 0 + } else if rhs > 0 { + lhs << rhs + } else { + lhs >> -rhs + } } pub fn exec_shift_right(mut lhs: &OwnedValue, mut rhs: &OwnedValue) -> OwnedValue {