Assessment reports>Pinocchio and p-token>Discussion>Missing mut in Pinocchio tests

Missing mut in Pinocchio tests

The tests in sdk/pinocchio/src/account_info.rs demonstrate uses of Ref. They construct a Ref object with a state field that is immutable. This is then passed to NonNull and set on the Ref instance. Later, in the Drop implementation, the state field is mutated, which is undefined behavior.

It does not appear that a Ref or RefMut can be easily constructed when using the library, so this does not raise this issue to the level of a finding, but it is suggested to change the tests to reflect that state should be mutable.

Zellic © 2025Back to top ↑