Skip to content

Commit

Permalink
fix some little bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kkHAIKE committed Sep 19, 2022
1 parent 95ac589 commit 4a70670
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -113,7 +113,7 @@ func call3() {
```

### force mark specify function have server-side http.Request parameter
default behavior is mark http.HandlerFunc only.
default behavior is mark http.HandlerFunc or a function use r.Context().

```go
// @contextcheck(req_has_ctx)
Expand Down
9 changes: 7 additions & 2 deletions contextcheck.go
Expand Up @@ -584,6 +584,7 @@ func (r *runner) checkFuncWithCtx(f *ssa.Function, tp entryType) {
func (r *runner) checkFuncWithoutCtx(f *ssa.Function, checkingMap map[string]bool) (ret bool) {
ret = true
orgKey := f.RelString(nil)
var seted bool
for _, b := range f.Blocks {
for _, instr := range b.Instrs {
tp, ok := r.getCtxType(instr)
Expand Down Expand Up @@ -614,7 +615,10 @@ func (r *runner) checkFuncWithoutCtx(f *ssa.Function, checkingMap map[string]boo
ret = false

// save the call link
r.setFact(orgKey, res.Valid, res.Funcs...)
if !seted {
seted = true
r.setFact(orgKey, res.Valid, res.Funcs...)
}
}
continue
}
Expand All @@ -638,7 +642,8 @@ func (r *runner) checkFuncWithoutCtx(f *ssa.Function, checkingMap map[string]boo

valid := r.checkFuncWithoutCtx(ff, checkingMap)
r.setFact(key, valid, ff.Name())
if res, ok := r.getValue(key, ff); ok {
if res, ok := r.getValue(key, ff); ok && !valid && !seted {
seted = true
r.setFact(orgKey, valid, res.Funcs...)
}
if !valid {
Expand Down

0 comments on commit 4a70670

Please sign in to comment.