1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

fix: initialize push notification processor in NewFailoverClient

- Add push processor initialization to NewFailoverClient to prevent nil pointer dereference
- Use VoidPushNotificationProcessor for failover clients (typically don't need push notifications)
- Ensure consistent behavior across all client creation paths including failover scenarios
- Complete the coverage of all client types that inherit from baseClient

This fixes the final nil pointer dereference that was occurring in failover client
contexts where the pushProcessor field was nil, causing segmentation violations
during Redis operations in sentinel-managed failover scenarios.
This commit is contained in:
Nedyalko Dyakov
2025-06-27 13:41:30 +03:00
parent a2de263588
commit ad16b21487

View File

@ -426,6 +426,14 @@ func NewFailoverClient(failoverOpt *FailoverOptions) *Client {
}
rdb.init()
// Initialize push notification processor to prevent nil pointer dereference
if opt.PushNotificationProcessor != nil {
rdb.pushProcessor = opt.PushNotificationProcessor
} else {
// Create void processor for failover client (typically doesn't need push notifications)
rdb.pushProcessor = NewVoidPushNotificationProcessor()
}
connPool = newConnPool(opt, rdb.dialHook)
rdb.connPool = connPool
rdb.onClose = rdb.wrappedOnClose(failover.Close)