Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Fix nil pointer derefernce issues #3379

Merged
merged 2 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions roomserver/storage/postgres/user_room_keys_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ func (s *userRoomKeysStatements) SelectAllPublicKeysForUser(ctx context.Context,
if errors.Is(err, sql.ErrNoRows) {
return nil, nil
}
if err != nil {
return nil, err
}
defer internal.CloseAndLogIfError(ctx, rows, "SelectAllPublicKeysForUser: failed to close rows")

resultMap := make(map[types.RoomNID]ed25519.PublicKey)
Expand Down
3 changes: 3 additions & 0 deletions roomserver/storage/sqlite3/user_room_keys_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ func (s *userRoomKeysStatements) SelectAllPublicKeysForUser(ctx context.Context,
if errors.Is(err, sql.ErrNoRows) {
return nil, nil
}
if err != nil {
return nil, err
}
defer internal.CloseAndLogIfError(ctx, rows, "SelectAllPublicKeysForUser: failed to close rows")

resultMap := make(map[types.RoomNID]ed25519.PublicKey)
Expand Down
3 changes: 2 additions & 1 deletion userapi/internal/user_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -939,11 +939,12 @@ func (a *UserInternalAPI) QueryAccountByPassword(ctx context.Context, req *api.Q
return nil
case bcrypt.ErrHashTooShort: // user exists, but probably a passwordless account
return nil
default:
case nil:
res.Exists = true
res.Account = acc
return nil
}
return err
}

func (a *UserInternalAPI) SetDisplayName(ctx context.Context, localpart string, serverName spec.ServerName, displayName string) (*authtypes.Profile, bool, error) {
Expand Down
Loading