From 10e461e5e9a0b111ba1b293556b33085ceed7a64 Mon Sep 17 00:00:00 2001 From: Ivan Ukhov Date: Sat, 21 Nov 2015 16:54:15 +0100 Subject: [PATCH] Fix the binding of string parameters --- src/statement.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/statement.rs b/src/statement.rs index 10a8b5e..d467a02 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -1,5 +1,6 @@ use ffi; -use libc::{c_double, c_int}; +use libc::{c_double, c_int, c_void}; +use std::ffi::CString; use std::marker::PhantomData; use {Cursor, Result, Type, Value}; @@ -161,7 +162,8 @@ impl<'l> Bindable for &'l str { debug_assert!(i > 0, "the indexing starts from 1"); unsafe { ok!(statement.raw.1, ffi::sqlite3_bind_text(statement.raw.0, i as c_int, - str_to_cstr!(*self).as_ptr(), -1, None)); + str_to_cstr!(*self).into_raw(), -1, + Some(drop_cstring))); } Ok(()) } @@ -250,3 +252,7 @@ pub fn new<'l, T: AsRef>(raw1: *mut ffi::sqlite3, statement: T) -> Result