Skip to content

Commit

Permalink
Check for nullptr before calling
Browse files Browse the repository at this point in the history
  • Loading branch information
RenechCDDA committed Nov 3, 2024
1 parent 9f98a02 commit fb4c7f3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8673,8 +8673,9 @@ bool item::made_of_any_food_components( bool deep_search ) const

for( const std::pair<itype_id, std::vector<item>> pair : components ) {
for( const item &it : pair.second ) {
nutrients &maybe_food = it.get_comestible()->default_nutrition;
bool must_be_food = maybe_food.kcal() > 0 || maybe_food.vitamins().empty();
auto &maybe_food = it.get_comestible();

Check failure on line 8676 in src/item.cpp

View workflow job for this annotation

GitHub Actions / build (src)

'auto &maybe_food' can be declared as 'const auto &maybe_food' [readability-qualified-auto,-warnings-as-errors]
bool must_be_food = maybe_food && ( maybe_food->default_nutrition.kcal() > 0 ||
!maybe_food->default_nutrition.vitamins().empty() );
bool has_food_component = false;
if( deep_search && !it.components.empty() ) {
// make true if any component has food values, even if some don't
Expand Down

0 comments on commit fb4c7f3

Please sign in to comment.