File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -273,9 +273,22 @@ impl<W: Wal> Connection<W> {
273273
274274 #[ cfg( not( feature = "rusqlite" ) ) ]
275275 let conn = unsafe {
276- use std:: os:: unix:: ffi:: OsStrExt ;
277- let path = std:: ffi:: CString :: new ( path. as_ref ( ) . as_os_str ( ) . as_bytes ( ) )
278- . map_err ( |_| crate :: error:: Error :: Bug ( "invalid database path" ) ) ?;
276+ #[ cfg( unix) ]
277+ let path = {
278+ use std:: os:: unix:: ffi:: OsStrExt ;
279+ std:: ffi:: CString :: new ( path. as_ref ( ) . as_os_str ( ) . as_bytes ( ) )
280+ . map_err ( |_| crate :: error:: Error :: Bug ( "invalid database path" ) )
281+ } ;
282+ #[ cfg( not( unix) ) ]
283+ let path = path
284+ . to_str ( )
285+ . ok_or_else ( || crate :: error:: Error :: Bug ( "datbase path is not valid unicode" ) )
286+ . and_then ( |x| {
287+ std:: ffi:: CString :: new ( x) . map_err ( |_| {
288+ crate :: error:: Error :: Bug ( "invalid database contains an internal nul byte" )
289+ } )
290+ } ) ?;
291+
279292 let mut conn: * mut crate :: ffi:: sqlite3 = std:: ptr:: null_mut ( ) ;
280293 // We pass a pointer to the WAL methods data to the database connection. This means
281294 // that the reference must outlive the connection. This is guaranteed by the marker in
You can’t perform that action at this time.
0 commit comments