From 0055b695167fdc5c24354939387253105ce43f59 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Sat, 3 Feb 2024 15:17:50 -0500 Subject: [PATCH] Protect against nil return objects --- db/db.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/db/db.go b/db/db.go index c8650515..76959ee5 100644 --- a/db/db.go +++ b/db/db.go @@ -652,7 +652,9 @@ func (db *DB) executeStmtWithConn(ctx context.Context, stmt *command.Statement, defer func() { if retErr != nil { retErr = rewriteContextTimeout(retErr, ErrExecuteTimeout) - res.Error = retErr.Error() + if res != nil { + res.Error = retErr.Error() + } } }() result := &command.ExecuteResult{} @@ -813,7 +815,9 @@ func (db *DB) queryStmtWithConn(ctx context.Context, stmt *command.Statement, xT defer func() { if retErr != nil { retErr = rewriteContextTimeout(retErr, ErrQueryTimeout) - retRows.Error = retErr.Error() + if retRows != nil { + retRows.Error = retErr.Error() + } } }() rows := &command.QueryRows{}