mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
fix: handle Query/QueryRow/transaction errors in channel server handlers
Add error checking and logging for ~25 database call sites that were silently dropping errors, preventing resource leaks (unclosed rows), nil pointer panics, and silent data corruption in festa transactions.
This commit is contained in:
@@ -95,11 +95,15 @@ func handleMsgMhfEnumerateHouse(s *Session, p mhfpacket.MHFPacket) {
|
||||
houseQuery = `SELECT c.id, hr, gr, name, COALESCE(ub.house_state, 2) as house_state, COALESCE(ub.house_password, '') as house_password
|
||||
FROM characters c LEFT JOIN user_binary ub ON ub.id = c.id WHERE name ILIKE $1`
|
||||
house := HouseData{}
|
||||
rows, _ := s.server.db.Queryx(houseQuery, fmt.Sprintf(`%%%s%%`, pkt.Name))
|
||||
for rows.Next() {
|
||||
err := rows.StructScan(&house)
|
||||
if err == nil {
|
||||
houses = append(houses, house)
|
||||
rows, err := s.server.db.Queryx(houseQuery, fmt.Sprintf(`%%%s%%`, pkt.Name))
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to query houses by name", zap.Error(err))
|
||||
} else {
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
if err := rows.StructScan(&house); err == nil {
|
||||
houses = append(houses, house)
|
||||
}
|
||||
}
|
||||
}
|
||||
case 4:
|
||||
|
||||
Reference in New Issue
Block a user