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

[Lua]Harden vessel dereferencing #519

Merged
merged 1 commit into from
Dec 15, 2024
Merged

Conversation

TheGondos
Copy link
Contributor

@TheGondos TheGondos commented Dec 1, 2024

This PR adds checks on the "self" parameter when a Lua command executes a virtual function on vessel objects.
Prior to this, there were opportunities for CTD when the user forgot to use the ":" notation when calling a vessel method.
A proper Lua error is now propagated when we try to convert a non vessel object to a VESSEL *.
Orbiter vessels providing Lua bindings have also been updated to check for proper type before casting userdata to VESSEL objects.
Note : luaL_checkudata is not used in the interpreter because we cannot know what type of vessel is to be expected. Instead a set of VESSEL objects is maintained and checked against to test if a userdata is associated with a known vessel.
This method is robust to vessel deletion. If for example you do
v=vessel.get_interface("ISS")
then delete the ISS from the scenario editor
then
print(v:get_name())
it generates an error instead of a crash.

@jarmonik jarmonik merged commit ce6db86 into orbitersim:main Dec 15, 2024
2 checks passed
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.

2 participants