forked from quic-go/quic-go
Make http3.client.Close() succeed if session was not started
Invoking http3.client.Close() before client.dial() is invoked causes a segmentation fault. That occurs because, in this circumstance, invoking client.Close() results in invoking client.session.CloseWithError(...) while client.session is nil. This commit changes the behavior of http3.client.Close() to return nil if client.session is nil and adds an associated test case.
This commit is contained in:
@@ -127,6 +127,9 @@ func (c *client) setupSession() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) Close() error {
|
func (c *client) Close() error {
|
||||||
|
if c.session == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return c.session.CloseWithError(quic.ErrorCode(errorNoError), "")
|
return c.session.CloseWithError(quic.ErrorCode(errorNoError), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -146,6 +146,12 @@ var _ = Describe("Client", func() {
|
|||||||
Expect(err).To(MatchError(testErr))
|
Expect(err).To(MatchError(testErr))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("closes correctly if session was not created", func() {
|
||||||
|
client = newClient("localhost:1337", nil, &roundTripperOpts{}, nil, nil)
|
||||||
|
err := client.Close()
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
})
|
||||||
|
|
||||||
Context("Doing requests", func() {
|
Context("Doing requests", func() {
|
||||||
var (
|
var (
|
||||||
request *http.Request
|
request *http.Request
|
||||||
|
|||||||
Reference in New Issue
Block a user