Skip to content

Commit

Permalink
expr: fix tikv crash when conv empty string (#12672) (#12692)
Browse files Browse the repository at this point in the history
ref #12672, close #12673

Fix tikv crash when conv empty string

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

Co-authored-by: Shenghui Wu <793703860@qq.com>
Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
  • Loading branch information
3 people committed Jun 14, 2022
1 parent 43456c6 commit b9e5d00
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/tidb_query_expr/src/impl_math.rs
Expand Up @@ -612,7 +612,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 Expand Up @@ -1573,6 +1573,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

0 comments on commit b9e5d00

Please sign in to comment.