File: 02-Bug%23854849_Fix_bind_cgo.patch

package info (click to toggle)
golang-github-mattn-go-sqlite3 1.1.0~dfsg1-3~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 292 kB
  • sloc: cpp: 1,132; makefile: 40; ansic: 30
file content (21 lines) | stat: -rw-r--r-- 1,021 bytes parent folder | download | duplicates (2)
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)))