C3D_BindProgram stores the passed-in pointer to a shader::Program in the C3D context. Currently, bind_program takes a reference to a Program, meaning that it's possible to pass in a Program that is dropped before the context attempts to use it (at the end of the frame, when it's rendered). This leads to a use-after-free and generally a crash.
This can be avoided by the Instance taking ownership of the passed-in Program, and storing it in some kind of data type that can be Pinned.
C3D_BindProgram
stores the passed-in pointer to ashader::Program
in the C3D context. Currently,bind_program
takes a reference to aProgram
, meaning that it's possible to pass in aProgram
that is dropped before the context attempts to use it (at the end of the frame, when it's rendered). This leads to a use-after-free and generally a crash. This can be avoided by theInstance
taking ownership of the passed-inProgram
, and storing it in some kind of data type that can bePin
ned.