Open Nils12345678901234567 opened 1 month ago
Thanks for the heads-up. I do not think that I entirely understand this issue: In the case of PythonFMU, they passed either a pointer to an object of a different type or a nullptr. In this case, the application would also crash when checking for the magic number.
Could you please explain, maybe give an example, in which cases you expect issues?
There is a risk that an invalid pointer is passed as component_environment. This is the case with the current release of https://github.com/NTNU-IHB/PythonFMU (https://github.com/NTNU-IHB/PythonFMU/pull/212)
I could be useful to add a magic number to the
wrapped_fmu
struct and check the validity of the pointer passed asfmi2ComponentEnvironment
:In fmi_wrapper.c add a new member to the start of the struct (Note: all code the uses the struct must be recompiled):
Initialize the value in `create_wrapper':
Check the magic number before acessing the pointer: