From 69c8df7119f78d10f966f3a0965c60f9c4a8280b Mon Sep 17 00:00:00 2001 From: localvar Date: Mon, 25 Nov 2019 09:37:20 +0800 Subject: [PATCH] fix tbase-1233: go connector cause client crash --- src/connector/go/src/taosSql/rows.go | 15 ++++++++------- src/connector/go/src/taosSql/taosSqlCgo.go | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/connector/go/src/taosSql/rows.go b/src/connector/go/src/taosSql/rows.go index 6407fc334e..5040dca06d 100755 --- a/src/connector/go/src/taosSql/rows.go +++ b/src/connector/go/src/taosSql/rows.go @@ -118,14 +118,15 @@ func (rows *taosSqlRows) ColumnTypeScanType(i int) reflect.Type { return rows.rs.columns[i].scanType() } -func (rows *taosSqlRows) Close() (err error) { - mc := rows.mc - if mc == nil { - return nil +func (rows *taosSqlRows) Close() error { + if rows.mc != nil { + result := C.taos_use_result(rows.mc.taos) + if result != nil { + C.taos_free_result(result) + } + rows.mc = nil } - - rows.mc = nil - return err + return nil } func (rows *taosSqlRows) HasNextResultSet() (b bool) { diff --git a/src/connector/go/src/taosSql/taosSqlCgo.go b/src/connector/go/src/taosSql/taosSqlCgo.go index fcef14045f..cc3aaa1658 100755 --- a/src/connector/go/src/taosSql/taosSqlCgo.go +++ b/src/connector/go/src/taosSql/taosSqlCgo.go @@ -39,7 +39,7 @@ func (mc *taosConn) taosConnect(ip, user, pass, db string, port int) (taos unsaf defer C.free(unsafe.Pointer(cpass)) defer C.free(unsafe.Pointer(cdb)) - taosObj := C.taos_connect(cip, cuser, cpass, cdb, (C.int)(port)) + taosObj := C.taos_connect(cip, cuser, cpass, cdb, (C.ushort)(port)) if taosObj == nil { return nil, errors.New("taos_connect() fail!") } -- GitLab