mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-07 18:24:20 +01:00
Prevent panic in extension by out of bounds cursor idx
This commit is contained in:
@@ -112,11 +112,14 @@ impl VTabModule for KVStoreVTab {
|
||||
if cursor.index.is_some_and(|c| c >= cursor.rows.len()) {
|
||||
return Err("cursor out of range".into());
|
||||
}
|
||||
let (_, ref key, ref val) = cursor.rows[cursor.index.unwrap_or(0)];
|
||||
match idx {
|
||||
0 => Ok(Value::from_text(key.clone())), // key
|
||||
1 => Ok(Value::from_text(val.clone())), // value
|
||||
_ => Err("Invalid column".into()),
|
||||
if let Some((_, ref key, ref val)) = cursor.rows.get(cursor.index.unwrap_or(0)) {
|
||||
match idx {
|
||||
0 => Ok(Value::from_text(key.clone())), // key
|
||||
1 => Ok(Value::from_text(val.clone())), // value
|
||||
_ => Err("Invalid column".into()),
|
||||
}
|
||||
} else {
|
||||
Err("cursor out of range".into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user