forked from mirror/go-sqlcipher
bug fix: Byte slices belong to the caller and so must be copies.
With the exeption of slices in the result type sql.RawBytes, new calls to Sqlite must not corrupt slices.
This commit is contained in:
parent
8f1b649756
commit
a4e5e7a617
|
@ -297,7 +297,14 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error {
|
||||||
case C.SQLITE_BLOB:
|
case C.SQLITE_BLOB:
|
||||||
n := int(C.sqlite3_column_bytes(rc.s.s, C.int(i)))
|
n := int(C.sqlite3_column_bytes(rc.s.s, C.int(i)))
|
||||||
p := C.sqlite3_column_blob(rc.s.s, C.int(i))
|
p := C.sqlite3_column_blob(rc.s.s, C.int(i))
|
||||||
|
switch dest[i].(type) {
|
||||||
|
case sql.RawBytes:
|
||||||
dest[i] = (*[1 << 30]byte)(unsafe.Pointer(p))[0:n]
|
dest[i] = (*[1 << 30]byte)(unsafe.Pointer(p))[0:n]
|
||||||
|
default:
|
||||||
|
slice := make([]byte, n)
|
||||||
|
copy(slice[:], (*[1 << 30]byte)(unsafe.Pointer(p))[0:n])
|
||||||
|
dest[i] = slice
|
||||||
|
}
|
||||||
case C.SQLITE_NULL:
|
case C.SQLITE_NULL:
|
||||||
dest[i] = nil
|
dest[i] = nil
|
||||||
case C.SQLITE_TEXT:
|
case C.SQLITE_TEXT:
|
||||||
|
|
Loading…
Reference in New Issue