-
-
Notifications
You must be signed in to change notification settings - Fork 224
ScriptInstance
implementation is currently unsound
#647
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
Comments
I am gonna work on fixing this after #625 is done. Also @TitanNano since you made the initial implementation, just wondering if you had any input here too. |
@lilizoey just leaving a quick comment so I don't forget. I am currently working on a patch that will switch I will try to share a draft soonish. |
Note that However, exposing So please consider discussing the design in a GitHub issue before spending a lot of time on implementation. |
Co-authored-by: Lili Zoey <[email protected]>
Co-authored-by: Lili Zoey <[email protected]>
Co-authored-by: Lili Zoey <[email protected]>
Store Property / Method list in ScriptInstanceData #647
In our script instance implementation, we pass a property list and method list to godot depending on slices returned from
get_property_list
andget_method_list
. Godot will then later callfree_property_list_func
andfree_method_list_func
on each of these. In these methods we again callget_property_list/get_method_list
to find the length of the array, and callVec::from_raw_parts(ptr, len, len)
on the pointer.This is unsound, since there is nothing stopping the user from implementing
get_property_list
orget_method_list
such that they return slices of different lengths each time. For instance we could do something like:This would make the
free
callback always try to create aVec
with a too big length, thus UB.Solutions
In godot 4.3 we can use the new free-callbacks, which pass along the length of the array. So that means we have at least these options:
ScriptInstance
support from all versions prior to 4.3, use new callbacks in 4.3I think option 1 is best. As making a sound implementation is tricky (you can use a sentinel value for the length, or some kind of header struct trick). And in 4.3 we wont need anything fancy for the length since the length is simply passed to us by Godot.
The text was updated successfully, but these errors were encountered: