Skip to content

Commit c5aee96

Browse files
committed
Merge pull request #267 from ianlancetaylor/go16
bind: pass &v[0] in direct call to C
2 parents 57d9aeb + b76c610 commit c5aee96

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sqlite3.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -815,11 +815,11 @@ func (s *SQLiteStmt) bind(args []driver.Value) error {
815815
case float64:
816816
rv = C.sqlite3_bind_double(s.s, n, C.double(v))
817817
case []byte:
818-
var p *byte
819-
if len(v) > 0 {
820-
p = &v[0]
818+
if len(v) == 0 {
819+
rv = C._sqlite3_bind_blob(s.s, n, nil, 0)
820+
} else {
821+
rv = C._sqlite3_bind_blob(s.s, n, unsafe.Pointer(&v[0]), C.int(len(v)))
821822
}
822-
rv = C._sqlite3_bind_blob(s.s, n, unsafe.Pointer(p), C.int(len(v)))
823823
case time.Time:
824824
b := []byte(v.Format(SQLiteTimestampFormats[0]))
825825
rv = C._sqlite3_bind_text(s.s, n, (*C.char)(unsafe.Pointer(&b[0])), C.int(len(b)))

0 commit comments

Comments
 (0)