1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

fix: add nil reader check in ProcessPendingNotifications to prevent panic

- Add nil check for proto.Reader parameter in both PushNotificationProcessor and VoidPushNotificationProcessor
- Prevent segmentation violation when ProcessPendingNotifications is called with nil reader
- Return early with nil error when reader is nil (graceful handling)
- Fix panic in TestProcessPendingNotificationsEdgeCases test

This addresses the runtime panic that occurred when rd.Buffered() was called on a nil reader,
ensuring robust error handling in edge cases where the reader might not be properly initialized.
This commit is contained in:
Nedyalko Dyakov
2025-06-27 14:39:22 +03:00
parent 03bfd9ffcc
commit 9a7a5c853b
2 changed files with 12 additions and 3 deletions

View File

@ -436,9 +436,9 @@ func (c *PubSub) newMessage(reply interface{}) (interface{}, error) {
default:
// Try to handle as generic push notification
ctx := c.getContext()
registry := c.pushProcessor.GetRegistry()
if registry != nil {
handled := registry.HandleNotification(ctx, reply)
handler := c.pushProcessor.GetHandler(kind)
if handler != nil {
handled := handler.HandlePushNotification(ctx, reply)
if handled {
// Return a special message type to indicate it was handled
return &PushNotificationMessage{