Skip to content

Commit

Permalink
Fix disposables in ApplicationEngine (neo-project#2191)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang authored and cloud8little committed Jan 24, 2021
1 parent 736a4e1 commit 8859ab1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
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

0 comments on commit 8859ab1

Please sign in to comment.