Skip to content

Commit

Permalink
bugfix: usage of nil in Connection.peekFuture()
Browse files Browse the repository at this point in the history
It may be possible to get a nil value from conn.getFutureImp(). We need
to check the value before using.
  • Loading branch information
oleg-jukovec committed Jul 25, 2022
1 parent 5498e2d commit 609268f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
- Build with OpenSSL < 1.1.1 (#194)
- Add `ExecuteAsync` and `ExecuteTyped` to common connector interface (#62)
- Race conditions in methods of `Future` type (#195)
- Usage of nil pointer in Connection.peekFuture (#195)

## [1.6.0] - 2022-06-01

Expand Down
11 changes: 6 additions & 5 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,11 +949,12 @@ func (conn *Connection) peekFuture(reqid uint32) (fut *Future) {
defer shard.rmut.Unlock()

if conn.opts.Timeout > 0 {
fut = conn.getFutureImp(reqid, true)
pair := &shard.requests[pos]
*pair.last = fut
pair.last = &fut.next
fut.timeout = time.Since(epoch) + conn.opts.Timeout
if fut = conn.getFutureImp(reqid, true); fut != nil {
pair := &shard.requests[pos]
*pair.last = fut
pair.last = &fut.next
fut.timeout = time.Since(epoch) + conn.opts.Timeout
}
} else {
fut = conn.getFutureImp(reqid, false)
}
Expand Down

0 comments on commit 609268f

Please sign in to comment.