neo
neo copied to clipboard
Fix: wrong reference count after invalid `Map[key] = value`
Description
When set a value to map, The old value reference removed in Line 55 or the new key reference added in Line 57.
But if Line 60 throws a InvalidOperationException, the reference count will be wrong,
because the ReferenceCounter has been updated, but the internal collection not.
https://github.com/neo-project/neo/blob/6c7f6c435e2fb308737b97cb1bc783c6a296bcc5/src/Neo.VM/Types/Map.cs#L52-L62
Type of change
- [ ] Optimization (the change is only an optimization)
- [ ] Style (the change is only a code style for better maintenance or standard purpose)
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules