From 85e456ef27b5b5a64214bc5a74cbf8ec3114f5e5 Mon Sep 17 00:00:00 2001 From: Greg Holt Date: Mon, 21 Aug 2017 13:30:07 -0700 Subject: [PATCH] Fix to pass TestNilAndEmptyBytes --- sqlite3.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sqlite3.go b/sqlite3.go index d0327b8..bff6b7c 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -867,10 +867,11 @@ func (s *SQLiteStmt) bind(args []namedValue) error { case float64: rv = C.sqlite3_bind_double(s.s, n, C.double(v)) case []byte: - if len(v) == 0 { + ln := len(v) + if ln == 0 { v = placeHolder } - rv = C._sqlite3_bind_blob(s.s, n, unsafe.Pointer(&v[0]), C.int(len(v))) + rv = C._sqlite3_bind_blob(s.s, n, unsafe.Pointer(&v[0]), C.int(ln)) case time.Time: b := []byte(v.Format(SQLiteTimestampFormats[0])) rv = C._sqlite3_bind_text(s.s, n, (*C.char)(unsafe.Pointer(&b[0])), C.int(len(b)))