Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expr: fix tikv crash when conv empty string (#12672) #12688

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions components/tidb_query/src/expr/builtin_math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,7 @@ mod tests {
("16九a", 10, 8, "20"),
("+", 10, 8, "0"),
("-", 10, 8, "0"),
("", 2, 16, "0"),
];
for (n, f, t, e) in tests {
let n = Datum::Bytes(n.as_bytes().to_vec());
Expand Down
2 changes: 1 addition & 1 deletion components/tidb_query/src/expr_util/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn is_valid_base(base: IntWithSign) -> bool {

fn extract_num_str(s: &str, from_base: IntWithSign) -> Option<(String, bool)> {
let mut iter = s.chars().peekable();
let head = *iter.peek().unwrap();
let head = *iter.peek()?;
let mut is_neg = false;
if head == '+' || head == '-' {
is_neg = head == '-';
Expand Down
1 change: 1 addition & 0 deletions components/tidb_query/src/rpn_expr/impl_math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,7 @@ mod tests {
("16九a", 10, 8, "20"),
("+", 10, 8, "0"),
("-", 10, 8, "0"),
("", 2, 16, "0"),
];
for (n, f, t, e) in tests {
let n = Some(n.as_bytes().to_vec());
Expand Down