From 90f22c17175fab5f9ad48abba5a18f5f2b5c9d2e Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Thu, 12 May 2016 08:00:53 -0500 Subject: [PATCH] Don't share inet constant memory between connections --- conn.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/conn.go b/conn.go index 31de46de..b9a6f356 100644 --- a/conn.go +++ b/conn.go @@ -144,14 +144,22 @@ func connect(config ConnConfig, pgTypes map[Oid]PgType, pgsql_af_inet *byte, pgs c = new(Conn) c.config = config + if pgTypes != nil { c.PgTypes = make(map[Oid]PgType, len(pgTypes)) for k, v := range pgTypes { c.PgTypes[k] = v } } - c.pgsql_af_inet = pgsql_af_inet - c.pgsql_af_inet6 = pgsql_af_inet6 + + if pgsql_af_inet != nil { + c.pgsql_af_inet = new(byte) + *c.pgsql_af_inet = *pgsql_af_inet + } + if pgsql_af_inet6 != nil { + c.pgsql_af_inet6 = new(byte) + *c.pgsql_af_inet6 = *pgsql_af_inet6 + } if c.config.LogLevel != 0 { c.logLevel = c.config.LogLevel