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

Ensure that we are dereferencing elements that exists #35

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

mpatou
Copy link
Contributor

@mpatou mpatou commented Nov 10, 2023

Summary

We were derefencing variables that could be nil.
For instance if the query don't return an error but just no lines then
doing err.Error() was causing a nil/null derefencing.
Similarly if the field array in the frame was has only one element doing

frame.Fields[1].Len()

Would result in a crash because we would derefence a nil pointer.

We are fixing this here. Also we are returning a nicer message when the
query results are empty.

Testing

Used a query that is returning no line, before the change this would
crash the plug-in after the change it's printing a nice(r) message
about the fact that the query is not returning lines.

Copy link
Contributor

@morganda morganda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the one lint issue lgtm

Copy link
Member

@pmenglund pmenglund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice

@mpatou
Copy link
Contributor Author

mpatou commented Nov 10, 2023

Besides the one lint issue lgtm

Oups will fix lint.

Summary
We were derefencing variables that could be nil.
For instance if the query don't return an error but just no lines then
doing err.Error() was causing a nil/null derefencing.
Similarly if the field array in the frame was has only one element doing
```
frame.Fields[1].Len()
 ```

Would result in a crash because we would derefence a nil pointer.

We are fixing this here. Also we are returning a nicer message when the
query results are empty.

Testing

Used a query that is returning no line, before the change this would
crash the plug-in after the change it's printing a nice(r) message
about the fact that the query is not returning lines.
@mpatou mpatou force-pushed the fix_plugin_crashes branch from b27b78f to 15f86e5 Compare November 10, 2023 02:58
@mpatou mpatou merged commit a0c6c89 into master Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants