Skip to content

Commit

Permalink
Fix panic in startingSequenceForSources (#4035)
Browse files Browse the repository at this point in the history
startingSequenceForSources had a potential panic at
`ssi.External.ApiPrefix`.
This checks if `External is not nil before matching its ApiPrefix.

cc @jnmoyne 

 Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
  • Loading branch information
derekcollison committed Apr 7, 2023
2 parents ce0d851 + 5715918 commit 51bb174
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion server/stream.go
Expand Up @@ -3031,7 +3031,7 @@ func (mset *stream) startingSequenceForSources() {
streamName, iName, sSeq := streamAndSeq(string(ss))
if iName == _EMPTY_ { // Pre-2.10 message header means it's a match for any source using that stream name
for _, ssi := range mset.cfg.Sources {
if streamName == ssi.Name || streamName == ssi.Name+":"+getHash(ssi.External.ApiPrefix) {
if streamName == ssi.Name || (ssi.External != nil && streamName == ssi.Name+":"+getHash(ssi.External.ApiPrefix)) {
update(ssi.iname, sSeq)
}
}
Expand Down

0 comments on commit 51bb174

Please sign in to comment.