Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIXED] Protect against possible nil pointer panic #1771

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion jetstream/jetstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ func (js *jetStream) StreamNames(ctx context.Context, opts ...StreamListOpt) Str
for _, opt := range opts {
if err := opt(&streamsReq); err != nil {
l.err = err
close(l.streams)
close(l.names)
return l
}
}
Expand Down
6 changes: 3 additions & 3 deletions nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -4685,14 +4685,14 @@ func (s *Subscription) Unsubscribe() error {
// checkDrained will watch for a subscription to be fully drained
// and then remove it.
func (nc *Conn) checkDrained(sub *Subscription) {
if nc == nil || sub == nil {
return
}
defer func() {
sub.mu.Lock()
defer sub.mu.Unlock()
sub.draining = false
}()
if nc == nil || sub == nil {
return
}

// This allows us to know that whatever we have in the client pending
// is correct and the server will not send additional information.
Expand Down
Loading