Skip to content

Commit

Permalink
Merge pull request #40233 from nphyx/item-pockets-crafting-segfault
Browse files Browse the repository at this point in the history
fix: segfault during crafting setup
  • Loading branch information
kevingranade authored May 6, 2020
2 parents afd8407 + 3355144 commit 62dd134
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8402,7 +8402,7 @@ bool item_ptr_compare_by_charges( const item *left, const item *right )
} else if( right->contents.empty() ) {
return true;
} else {
return right->contents.legacy_front().charges < left->contents.legacy_front().charges;
return right->contents.only_item().charges < left->contents.only_item().charges;
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/item_contents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,11 +667,19 @@ std::list<const item *> item_contents::all_items_ptr() const

item &item_contents::legacy_front()
{
if( empty() ) {
debugmsg( "naively asked for first content item and will get a nullptr" );
return null_item_reference();
}
return *all_items_top().front();
}

const item &item_contents::legacy_front() const
{
if( empty() ) {
debugmsg( "naively asked for first content item and will get a nullptr" );
return null_item_reference();
}
return *all_items_top().front();
}

Expand Down

0 comments on commit 62dd134

Please sign in to comment.