Skip to content
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

Evidence store may leak resource #2515

Closed
goolAdapter opened this issue Sep 29, 2018 · 1 comment
Closed

Evidence store may leak resource #2515

goolAdapter opened this issue Sep 29, 2018 · 1 comment

Comments

@goolAdapter
Copy link
Contributor

goolAdapter commented Sep 29, 2018

there is a leak, iter need defer iter.Close().

iter := dbm.IteratePrefix(store.db, []byte(prefixKey))
for ; iter.Valid(); iter.Next() {

by the way,

l2 := make([]types.Evidence, len(l))
for i := range l {
l2[i] = l[len(l)-1-i]
}

should replace with reversing trick to eliminate temp slice.

for i := len(a)/2-1; i >= 0; i-- {
	opp := len(a)-1-i
	a[i], a[opp] = a[opp], a[i]
}

I'll make a PR for this issue.

@melekes
Copy link
Contributor

melekes commented Oct 2, 2018

Merged to develop. Thanks!

@melekes melekes closed this as completed Oct 2, 2018
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

No branches or pull requests

2 participants