Skip to content

Conversation

@Howard20181
Copy link

@Howard20181 Howard20181 commented Dec 18, 2025

Added a nil check for q.conn in the QUIC Close method to avoid potential nil pointer dereference errors when closing a QUIC connection.

Fixes the panic caused by attempting to close a connection when QUIC connection establishment fails: runtime error: invalid memory address or nil pointer dereference.

Test: Manual

q @quic://dns.google www.google.com

Summary by cubic

Prevented a panic in QUIC Close by making it a no-op when the connection was never established. This makes Close safe to call after failed QUIC setup.

  • Bug Fixes
    • Guard q.conn in Close(); return nil if it's nil, otherwise call CloseWithError.

Written for commit 7d1cba9. Summary will update automatically on new commits.

Added a nil check for q.conn in the QUIC Close method to avoid potential nil pointer dereference errors when closing a QUIC connection.

Fixes the panic caused by attempting to close a connection when QUIC connection establishment fails: runtime error: invalid memory address or nil pointer dereference.

Test: Manual

```shell
q @quic://dns.google www.google.com
```
Copilot AI review requested due to automatic review settings December 18, 2025 18:04
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a nil check to the QUIC transport's Close method to prevent a nil pointer dereference panic when the method is called before a connection is successfully established.

  • Added a nil check for q.conn before calling CloseWithError
  • Returns nil when connection is nil, avoiding panic
  • Aligns with similar patterns in TLS and HTTP transports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +153 to +155
if q.conn == nil {
return nil
}
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nil check for q.conn is correct and prevents a panic when Close is called before a connection is established. However, consider adding a test case that explicitly verifies Close can be called safely on a QUIC transport instance before any connection is established. This would ensure the bug fix is covered and prevent regression.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant