mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
In the second constructor, a new LinearSystem is created and set to m_plant. This takes a const ref though, so it's storing a reference to a temporary object. After the constructor finishes, m_plant points to an invalid object. When Update() is called, it will crash with a segmentation fault. This patch fixes the use-after-free by making m_plant a LinearSystem value type. The first constructor will generate a copy, but that only happens once.