ETLCPP / etl

Embedded Template Library
https://www.etlcpp.com
MIT License
2.25k stars 393 forks source link

Can call `get_succesor()` method of `fsm` class without setting a successor. #958

Closed kingtom22 closed 2 months ago

kingtom22 commented 2 months ago

Hi,

Firstly, thank You for developing and maintaining this library, it is very useful. I found that get_succesor() method of fsm can be called without setting a successor and the function will dereference a nullptr in that case. It is not written in the documentation that the user of the framework must call the has_succesor() method before using the get_succesor() method. I recommend to throw an exception or add this requirement to the documentation.

jwellbelove commented 2 months ago

I shall look at adding an ETL_ASSERT

jwellbelove commented 2 months ago

It may also be viable to make the return an etl::optional.

jwellbelove commented 2 months ago

I've just checked, and get_successor() asserts an etl::successor_invalid if no successor has been set.

kingtom22 commented 2 months ago

I see, in version 19.5.0 etl::succesor has been added, and that implements that check before using pointer of the successor. The issue can be closed. Thank You, for Your help!