-
Notifications
You must be signed in to change notification settings - Fork 373
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(vm): avoid "index out of range" in convertArgToGno
#2500
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Norman Meier <[email protected]>
n0izn0iz
changed the title
fix(vm): avoid index-out-of-range in convertArgToGno
fix(vm): avoid "index out of range" in Jul 4, 2024
convertArgToGno
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2500 +/- ##
==========================================
- Coverage 54.96% 54.84% -0.12%
==========================================
Files 595 595
Lines 79568 79294 -274
==========================================
- Hits 43734 43492 -242
+ Misses 32527 32520 -7
+ Partials 3307 3282 -25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Norman Meier <[email protected]>
thehowl
approved these changes
Jul 4, 2024
gfanton
pushed a commit
to gfanton/gno
that referenced
this pull request
Jul 23, 2024
With this gno code: ```go // foo.gno func Foo(val uint64) ``` Currently, passing an empty string where a numeric argument is expected in a vm call such as: ```go msg := MsgCall{ // (...) Func: "Foo", Args: []string{""}, } vmkeeper.Call(ctx, msg) ``` Will error out with: ``` runtime error: index out of range [0] with length 0 ``` Because the argument conversion routine accesses the first character to see if it's a `+` without first checking the length of the string This runtime error is confusing IMO and this PR makes the resulting error more meaningful, for example: ``` error parsing uint64 "": strconv.ParseUint: parsing "": invalid syntax ``` also increases `gnoland` code coverage by ~2% as a bonus ;) --------- Signed-off-by: Norman Meier <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With this gno code:
Currently, passing an empty string where a numeric argument is expected in a vm call such as:
Will error out with:
Because the argument conversion routine accesses the first character to see if it's a
+
without first checking the length of the stringThis runtime error is confusing IMO and this PR makes the resulting error more meaningful, for example:
also increases
gnoland
code coverage by ~2% as a bonus ;)