-
Notifications
You must be signed in to change notification settings - Fork 1k
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]
unalignment memory load in Neo.VM Unsafe.NotZero(ReadOnlySpan<byte>) and remove the use of unsafe
#3492
base: master
Are you sure you want to change the base?
Changes from all commits
7cf2e7f
37f78c8
2031460
a4ef07d
6315b28
cf362b7
d3fc7d2
68c67bf
fbedd90
b19adcb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -257,3 +257,5 @@ paket-files/ | |
PublishProfiles | ||
/.vscode | ||
launchSettings.json | ||
/coverages | ||
**/.DS_Store |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,17 @@ | |
StrictUTF8.EncoderFallback = EncoderFallback.ExceptionFallback; | ||
} | ||
|
||
/// <summary> | ||
/// All bytes are zero or not in a byte array | ||
/// </summary> | ||
/// <param name="x">The byte array</param> | ||
/// <returns>false if all bytes are zero, true otherwise</returns> | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static bool NotZero(this ReadOnlySpan<byte> x) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be moved to the extensions library. For There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Move it with the rest of the content together? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just that extension method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would like this method to be moved to |
||
{ | ||
return x.IndexOfAnyExcept((byte)0) >= 0; | ||
Check failure on line 38 in src/Neo.VM/Utility.cs GitHub Actions / Test-Everything
Check failure on line 38 in src/Neo.VM/Utility.cs GitHub Actions / Test-Everything
Check failure on line 38 in src/Neo.VM/Utility.cs GitHub Actions / Test (macos-latest)
Check failure on line 38 in src/Neo.VM/Utility.cs GitHub Actions / Test (macos-latest)
|
||
} | ||
|
||
public static bool TryGetString(this ReadOnlySpan<byte> bytes, out string? value) | ||
{ | ||
try | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation is quite straightforward, but
GetBoolean
is frequently-used in VM, thus we have to check mainnet/testnet networks for compatibility. There should be no issues, but let's do it just in case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@superboyiii could you check it?