mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
Check Rust blob length before binding.
This commit is contained in:
parent
7b8051dc7e
commit
9c63b9f37a
@ -122,6 +122,9 @@ impl ToSql for String {
|
|||||||
|
|
||||||
impl<'a> ToSql for &'a [u8] {
|
impl<'a> ToSql for &'a [u8] {
|
||||||
unsafe fn bind_parameter(&self, stmt: *mut sqlite3_stmt, col: c_int) -> c_int {
|
unsafe fn bind_parameter(&self, stmt: *mut sqlite3_stmt, col: c_int) -> c_int {
|
||||||
|
if self.len() > ::std::i32::MAX as usize {
|
||||||
|
return ffi::SQLITE_TOOBIG;
|
||||||
|
}
|
||||||
ffi::sqlite3_bind_blob(
|
ffi::sqlite3_bind_blob(
|
||||||
stmt, col, mem::transmute(self.as_ptr()), self.len() as c_int, ffi::SQLITE_TRANSIENT())
|
stmt, col, mem::transmute(self.as_ptr()), self.len() as c_int, ffi::SQLITE_TRANSIENT())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user