Skip to content

Commit 671cd2e

Browse files
committed
fix skip net/http.Request method call condition
1 parent 2be241c commit 671cd2e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

reqwithoutctx/ssa.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (a *Analyzer) usedReqByCall(call *ssa.Call) []*ssa.Extract {
9797
exts := make([]*ssa.Extract, 0, len(args))
9898

9999
// skip net/http.Request method call
100-
if call.Common().Signature().Recv() != nil && types.Identical(call.Value().Type(), a.requestType) {
100+
if recv := call.Common().Signature().Recv(); recv != nil && types.Identical(recv.Type(), a.requestType) {
101101
return exts
102102
}
103103

testdata/src/a/a.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,9 @@ func main() {
129129

130130
return req14, req15
131131
}()
132+
133+
req121, _ := http.NewRequest(http.MethodPost, url, nil) // OK
134+
req121.AddCookie(&http.Cookie{Name: "k", Value: "v"})
135+
req121 = req121.WithContext(context.WithValue(req.Context(), struct{}{}, 0))
136+
cli.Do(req121)
132137
}

0 commit comments

Comments
 (0)