From ef9e26a5d5a6ae7f6f8dd8570e181c08f114de9c Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 15 Jul 2023 10:16:28 -0500 Subject: [PATCH] Check nil in defer A panic might mean that pbr is nil. https://github.com/jackc/pgx/issues/1689 --- conn.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conn.go b/conn.go index a609d100..9722e130 100644 --- a/conn.go +++ b/conn.go @@ -1064,7 +1064,7 @@ func (c *Conn) sendBatchQueryExecModeDescribeExec(ctx context.Context, b *Batch) func (c *Conn) sendBatchExtendedWithDescription(ctx context.Context, b *Batch, distinctNewQueries []*pgconn.StatementDescription, sdCache stmtcache.Cache) (pbr *pipelineBatchResults) { pipeline := c.pgConn.StartPipeline(context.Background()) defer func() { - if pbr.err != nil { + if pbr != nil && pbr.err != nil { pipeline.Close() } }()