Skip to content

Fix nil pointer panic when cancelling an intercepted request#159

Open
SAY-5 wants to merge 1 commit into
dstotijn:mainfrom
SAY-5:fix-cancelrequest-nil-panic
Open

Fix nil pointer panic when cancelling an intercepted request#159
SAY-5 wants to merge 1 commit into
dstotijn:mainfrom
SAY-5:fix-cancelrequest-nil-panic

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jun 26, 2026

Copy link
Copy Markdown

CancelRequest calls ModifyRequest(reqID, nil, nil) to abort an intercepted request, but ModifyRequest dereferences modReq (*modReq = *modReq.WithContext(...)) before checking it, so cancelling any intercepted request panics with a nil pointer dereference.

ClearRequests already aborts by sending nil straight to the request channel. This adds the same handling to ModifyRequest: when modReq is nil, forward nil to the channel as the abort signal instead of dereferencing it. The waiting RequestModifier then returns ErrRequestAborted as intended.

Added a regression test that cancels a pending intercepted request and confirms it no longer panics.

Fixes #145

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
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.

nil pointer dereference panic in CancelRequest / ModifyRequest

1 participant