1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
This patch fixes cgo's pointer runtime panic
Ported from https://github.com/mattn/go-sqlite3/commit/b76c61051faaf0baf3215e6f811003d98639b702Index: golang-github-mattn-go-sqlite3-1.1.0~dfsg1/sqlite3.go
===================================================================
--- golang-github-mattn-go-sqlite3-1.1.0~dfsg1.orig/sqlite3.go 2015-09-05 23:49:54.000000000 +0900
+++ golang-github-mattn-go-sqlite3-1.1.0~dfsg1/sqlite3.go 2017-02-11 14:16:40.738620174 +0900
@@ -480,11 +480,11 @@
case float64:
rv = C.sqlite3_bind_double(s.s, n, C.double(v))
case []byte:
- var p *byte
- if len(v) > 0 {
- p = &v[0]
+ if len(v) == 0 {
+ rv = C._sqlite3_bind_blob(s.s, n, nil, 0)
+ } else {
+ 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(p), C.int(len(v)))
case time.Time:
b := []byte(v.UTC().Format(SQLiteTimestampFormats[0]))
rv = C._sqlite3_bind_text(s.s, n, (*C.char)(unsafe.Pointer(&b[0])), C.int(len(b)))
|