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

Fix disposables in ApplicationEngine #2191

Merged
merged 1 commit into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/neo/SmartContract/ApplicationEngine.Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,13 @@ protected internal byte[] Get(StorageContext context, byte[] key)
protected internal IIterator Find(StorageContext context, byte[] prefix)
{
byte[] prefix_key = StorageKey.CreateSearchPrefix(context.Id, prefix);
StorageIterator iterator = new StorageIterator(Snapshot.Storages.Find(prefix_key).GetEnumerator());
Disposables.Add(iterator);
return iterator;
return new StorageIterator(Snapshot.Storages.Find(prefix_key).GetEnumerator());
}

protected internal IEnumerator FindKeys(StorageContext context, byte[] prefix, byte removePrefix)
{
byte[] prefix_key = StorageKey.CreateSearchPrefix(context.Id, prefix);
StorageKeyEnumerator enumerator = new StorageKeyEnumerator(Snapshot.Storages.Find(prefix_key).Select(p => p.Key).GetEnumerator(), removePrefix);
Disposables.Add(enumerator);
return enumerator;
return new StorageKeyEnumerator(Snapshot.Storages.Find(prefix_key).Select(p => p.Key).GetEnumerator(), removePrefix);
}

protected internal void Put(StorageContext context, byte[] key, byte[] value)
Expand Down
1 change: 1 addition & 0 deletions src/neo/SmartContract/ApplicationEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public ExecutionContext LoadScript(Script script, ushort pcount = 0, int rvcount

protected internal StackItem Convert(object value)
{
if (value is IDisposable disposable) Disposables.Add(disposable);
return value switch
{
null => StackItem.Null,
Expand Down