File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -931,6 +931,10 @@ func (c *SQLiteConn) Serialize(schema string) []byte {
931931// byte slice. If deserelization fails, error will contain the return code
932932// of the underlying SQLite API call.
933933//
934+ // Because the byte slice is in Go-controlled memory, this function
935+ // makes a copy of the data in C-controlled memory, before passing the
936+ // data to the SQLite library.
937+ //
934938// See https://www.sqlite.org/c3ref/deserialize.html
935939func (c * SQLiteConn ) Deserialize (b []byte , schema string ) error {
936940 if schema == "" {
@@ -941,8 +945,9 @@ func (c *SQLiteConn) Deserialize(b []byte, schema string) error {
941945 defer C .free (unsafe .Pointer (zSchema ))
942946
943947 rc := C .sqlite3_deserialize (c .db , zSchema ,
944- (* C .uint8_t )(unsafe .Pointer (& b [0 ])),
945- C .sqlite3_int64 (len (b )), C .sqlite3_int64 (len (b )), 0 )
948+ (* C .uint8_t )(C .CBytes (b )),
949+ C .sqlite3_int64 (len (b )), C .sqlite3_int64 (len (b )),
950+ C .SQLITE_DESERIALIZE_FREEONCLOSE | C .SQLITE_DESERIALIZE_RESIZEABLE )
946951 if rc != 0 {
947952 return fmt .Errorf ("deserialize failed with return %v" , rc )
948953 }
You can’t perform that action at this time.
0 commit comments