Fix nil pointer dereference for userRoomKeysStatements

This commit is contained in:
Till Faelligen 2024-05-22 20:38:12 +02:00
parent 46902e5766
commit 56c979d117
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E
2 changed files with 6 additions and 0 deletions

View file

@ -162,6 +162,9 @@ func (s *userRoomKeysStatements) SelectAllPublicKeysForUser(ctx context.Context,
if errors.Is(err, sql.ErrNoRows) { if errors.Is(err, sql.ErrNoRows) {
return nil, nil return nil, nil
} }
if err != nil {
return nil, err
}
defer internal.CloseAndLogIfError(ctx, rows, "SelectAllPublicKeysForUser: failed to close rows") defer internal.CloseAndLogIfError(ctx, rows, "SelectAllPublicKeysForUser: failed to close rows")
resultMap := make(map[types.RoomNID]ed25519.PublicKey) resultMap := make(map[types.RoomNID]ed25519.PublicKey)

View file

@ -177,6 +177,9 @@ func (s *userRoomKeysStatements) SelectAllPublicKeysForUser(ctx context.Context,
if errors.Is(err, sql.ErrNoRows) { if errors.Is(err, sql.ErrNoRows) {
return nil, nil return nil, nil
} }
if err != nil {
return nil, err
}
defer internal.CloseAndLogIfError(ctx, rows, "SelectAllPublicKeysForUser: failed to close rows") defer internal.CloseAndLogIfError(ctx, rows, "SelectAllPublicKeysForUser: failed to close rows")
resultMap := make(map[types.RoomNID]ed25519.PublicKey) resultMap := make(map[types.RoomNID]ed25519.PublicKey)