Skip to content

Commit 686ed2f

Browse files
committed
Fix cast_text_to_* panicing on empty input
1 parent d408dec commit 686ed2f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/vdbe/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -3680,7 +3680,9 @@ fn affinity(datatype: &str) -> Affinity {
36803680
/// The CAST operator understands decimal integers only — conversion of hexadecimal integers stops at the "x" in the "0x" prefix of the hexadecimal integer string and thus result of the CAST is always zero.
36813681
fn cast_text_to_integer(text: &str) -> OwnedValue {
36823682
let text = text.trim();
3683-
3683+
if text.is_empty() {
3684+
return OwnedValue::Integer(0);
3685+
}
36843686
if let Ok(i) = text.parse::<i64>() {
36853687
return OwnedValue::Integer(i);
36863688
}
@@ -3702,6 +3704,9 @@ fn cast_text_to_integer(text: &str) -> OwnedValue {
37023704
/// If there is no prefix that can be interpreted as a real number, the result of the conversion is 0.0.
37033705
fn cast_text_to_real(text: &str) -> OwnedValue {
37043706
let trimmed = text.trim_start();
3707+
if trimmed.is_empty() {
3708+
return OwnedValue::Float(0.0);
3709+
}
37053710
if let Ok(num) = trimmed.parse::<f64>() {
37063711
return OwnedValue::Float(num);
37073712
}

0 commit comments

Comments
 (0)