Skip to content

Commit

Permalink
Fix KeyExists leak (#6353)
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams authored Dec 11, 2023
1 parent c284fa1 commit 600b7b6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Nethermind/Nethermind.Core/IKeyValueStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ public interface IReadOnlyKeyValueStore
/// <returns>Can return null or empty Span on missing key</returns>
Span<byte> GetSpan(ReadOnlySpan<byte> key, ReadFlags flags = ReadFlags.None) => Get(key, flags);

bool KeyExists(ReadOnlySpan<byte> key) => GetSpan(key).IsNull();
bool KeyExists(ReadOnlySpan<byte> key)
{
Span<byte> span = GetSpan(key);
bool result = span.IsNull();
DangerousReleaseMemory(span);
return result;
}

void DangerousReleaseMemory(in Span<byte> span) { }
}

Expand Down

0 comments on commit 600b7b6

Please sign in to comment.