Skip to content

More deserialize fixes #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions sqlite3.go
Original file line number Diff line number Diff line change
Expand Up @@ -931,9 +931,9 @@ func (c *SQLiteConn) Serialize(schema string) []byte {
// byte slice. If deserelization fails, error will contain the return code
// of the underlying SQLite API call.
//
// Because the byte slice is in Go-controlled memory, this function
// makes a copy of the data in C-controlled memory, before passing the
// data to the SQLite library.
// When this function returns, the connection is referencing database
// data in Go space, so the connection and associated database must be copied
// immediately if it is to be used further.
//
// See https://www.sqlite.org/c3ref/deserialize.html
func (c *SQLiteConn) Deserialize(b []byte, schema string) error {
Expand All @@ -945,9 +945,8 @@ func (c *SQLiteConn) Deserialize(b []byte, schema string) error {
defer C.free(unsafe.Pointer(zSchema))

rc := C.sqlite3_deserialize(c.db, zSchema,
(*C.uint8_t)(C.CBytes(b)),
C.sqlite3_int64(len(b)), C.sqlite3_int64(len(b)),
C.SQLITE_DESERIALIZE_FREEONCLOSE|C.SQLITE_DESERIALIZE_RESIZEABLE)
(*C.uint8_t)(unsafe.Pointer(&b[0])),
C.sqlite3_int64(len(b)), C.sqlite3_int64(len(b)), 0)
if rc != 0 {
return fmt.Errorf("deserialize failed with return %v", rc)
}
Expand Down