-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix GetAll() potentially return an unprotected map #139
Conversation
pkg/cover/store.go
Outdated
l.mu.RLock() | ||
defer l.mu.RUnlock() | ||
return l.servicesMap | ||
for k,v := range l.servicesMap { | ||
res[k] = append(make([]string,0,len(v)), v...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest to just use
res[k]=v
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
res[k]=v
is not totally safe if the caller modify the slice with index
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v is not a pointer of the actual value of l.servicesMap
. FYI: https://github.com/golang/go/wiki/Range#gotchas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CarlJi, v is slice, it is sth like pointer
Codecov Report
@@ Coverage Diff @@
## master #139 +/- ##
==========================================
+ Coverage 75.18% 75.21% +0.02%
==========================================
Files 37 37
Lines 2019 2021 +2
==========================================
+ Hits 1518 1520 +2
Misses 358 358
Partials 143 143
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/assign lyyyuna |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gavwu, lyyyuna The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
#137