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 panic when Render method is not declared in smart contract #489

Merged
merged 1 commit into from
Jan 30, 2023

Conversation

yassinouider
Copy link
Contributor

In function handleRealmRender, when the error returned by makeRequest is "Render not declared", the code tries to write to the res variable, which is nil. This causes a panic in the server.

Steps to reproduce:

  1. Make a request to the server for a realm that has no Render() function
  2. Observe the server panic

Fix:
I added the line "res = &abci.ResponseQuery{}" before writing to the res.Data variable. This creates an instance of abci.ResponseQuery and prevents the panic.

@yassinouider yassinouider requested a review from a team as a code owner January 29, 2023 13:44
@yassinouider
Copy link
Contributor Author

Hi @moul will realm without Render be allowed or should a check be applied before deploying them?

@moul
Copy link
Member

moul commented Jan 29, 2023

A realm without Render makes sense.

We need to manage this case without panic.

@moul moul merged commit c1a799d into gnolang:master Jan 30, 2023
@yassinouider yassinouider deleted the fix-render-panic branch January 31, 2023 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants