-
Notifications
You must be signed in to change notification settings - Fork 60
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: libwaku's invalid waku message error handling #3301
fix: libwaku's invalid waku message error handling #3301
Conversation
You can find the image built from this PR at
Built from 7a3d2f2 |
@@ -297,7 +297,6 @@ proc waku_relay_publish( | |||
jsonMessage = JsonMessage.fromJsonNode(jsonContent).valueOr: | |||
raise newException(JsonParsingError, $error) | |||
except JsonParsingError: | |||
deallocShared(jwm) |
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.
Is jwm
deallocated on finally
, even if we have the return
on line 302?
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.
Good question. I think it should.
Nevertheless, @gabrielmer I think it is safer to use the defer
approach in this case too.
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.
My understanding is that yes, but agree - let's use defer
:)
@@ -297,7 +297,6 @@ proc waku_relay_publish( | |||
jsonMessage = JsonMessage.fromJsonNode(jsonContent).valueOr: | |||
raise newException(JsonParsingError, $error) | |||
except JsonParsingError: | |||
deallocShared(jwm) |
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.
Good question. I think it should.
Nevertheless, @gabrielmer I think it is safer to use the defer
approach in this case too.
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.
LGTM!!!
Description
Checking if required
WakuMessage
fields exist before trying to access them and returning an error in case they are not present in the message.Additionally, fixing double dealloc in case of failure.
Changes
Issue