Skip to content

Commit

Permalink
fix(server::entity): check for nil before closing
Browse files Browse the repository at this point in the history
  • Loading branch information
rumblefrog committed Dec 30, 2019
1 parent 7281ed9 commit 62c6dde
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server/entity/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ func FetchEntity(id string) (*Entity, error) {
// Specify the column names for backward compat with old database
stmt, err := database.Connection.Prepare("SELECT `id`, `display_name`, `receive_channels`, `send_channels`, `disabled_receive_types`, `disabled_send_types`, `created_at` FROM `relay_entities` WHERE `id` = ?")

defer stmt.Close()
if stmt != nil {
defer stmt.Close()
}

if err != nil {
return nil, err
Expand Down Expand Up @@ -51,7 +53,9 @@ func FetchEntities() ([]*Entity, error) {
// Specify the column names for backward compat with old database
rows, err := database.Connection.Query("SELECT `id`, `display_name`, `receive_channels`, `send_channels`, `disabled_receive_types`, `disabled_send_types`, `created_at` FROM `relay_entities`")

defer rows.Close()
if rows != nil {
defer rows.Close()
}

if err != nil {
return nil, err
Expand Down

0 comments on commit 62c6dde

Please sign in to comment.