Skip to content

Commit 2e9e76f

Browse files
authored
Merge pull request #74 from xhit/fix-issue73
Don't get pointer of inexistent index when data is empty binding []byte
2 parents 59457a4 + aaa266b commit 2e9e76f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

param.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ func (p *Parameter) BindValue(h api.SQLHSTMT, idx int, v driver.Value) error {
128128
b := make([]byte, len(d))
129129
copy(b, d)
130130
p.Data = b
131-
buf = unsafe.Pointer(&b[0])
131+
if len(d) > 0 {
132+
buf = unsafe.Pointer(&b[0])
133+
}
132134
buflen = api.SQLLEN(len(b))
133135
plen = p.StoreStrLen_or_IndPtr(buflen)
134136
size = api.SQLULEN(len(b))

0 commit comments

Comments
 (0)