Skip to content

Commit

Permalink
call sqlite3_column_blob() before sqlite3_column_bytes()
Browse files Browse the repository at this point in the history
sqlite3 documentation states sqlite3_column_blob could modify the
the content and recommends the "safest and easiest" policy is to
invoke sqlite3_column_blob() followed by sqlite3_column_bytes()

from: http://www.sqlite.org/c3ref/column_blob.html
  • Loading branch information
dajohi committed Aug 2, 2013
1 parent dc751dd commit ecc4ab4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sqlite3.go
Expand Up @@ -373,8 +373,8 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error {
case C.SQLITE_FLOAT:
dest[i] = float64(C.sqlite3_column_double(rc.s.s, C.int(i)))
case C.SQLITE_BLOB:
n := int(C.sqlite3_column_bytes(rc.s.s, C.int(i)))
p := C.sqlite3_column_blob(rc.s.s, C.int(i))
n := int(C.sqlite3_column_bytes(rc.s.s, C.int(i)))
switch dest[i].(type) {
case sql.RawBytes:
dest[i] = (*[1 << 30]byte)(unsafe.Pointer(p))[0:n]
Expand Down

0 comments on commit ecc4ab4

Please sign in to comment.