From d12d3a4d8cb41d927a3cbcf7a457bd0a06f0bceb Mon Sep 17 00:00:00 2001 From: Jan Mercl <0xjnml@gmail.com> Date: Tue, 12 Jan 2021 17:50:29 +0100 Subject: [PATCH] handle binding zero length blobs, updates #40 --- sqlite.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sqlite.go b/sqlite.go index b95379c..778b42e 100644 --- a/sqlite.go +++ b/sqlite.go @@ -993,7 +993,9 @@ func (c *conn) bindBlob(pstmt uintptr, idx1 int, value []byte) (uintptr, error) return 0, err } - copy((*libc.RawMem)(unsafe.Pointer(p))[:len(value):len(value)], value) + if len(value) != 0 { + copy((*libc.RawMem)(unsafe.Pointer(p))[:len(value):len(value)], value) + } if rc := sqlite3.Xsqlite3_bind_blob(c.tls, pstmt, int32(idx1), p, int32(len(value)), 0); rc != sqlite3.SQLITE_OK { c.free(p) return 0, c.errstr(rc)