Skip to content

Commit

Permalink
Foodperson mask segfault fix (CleverRaven#45437)
Browse files Browse the repository at this point in the history
* Foodperson mask exploit repair

* Prevent possible segfault crash
  • Loading branch information
RoyBerube authored Nov 24, 2020
1 parent d853602 commit 541150b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/advanced_inv_pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "advanced_inv_pane.h"
#include "avatar.h"
#include "cata_assert.h"
#include "flag.h"
#include "item.h"
#include "item_contents.h"
#include "item_search.h"
Expand Down Expand Up @@ -109,7 +110,7 @@ std::vector<advanced_inv_listitem> avatar::get_AIM_inventory( const advanced_inv

int worn_index = -2;
for( item &worn_item : worn ) {
if( worn_item.contents.empty() ) {
if( worn_item.contents.empty() || worn_item.has_flag( flag_NO_UNLOAD ) ) {
continue;
}
for( const std::vector<item *> &it_stack : item_list_to_stack(
Expand Down
5 changes: 5 additions & 0 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7872,6 +7872,11 @@ int iuse::ehandcuffs( player *p, item *it, bool t, const tripoint &pos )

int iuse::foodperson( player *p, item *it, bool t, const tripoint &pos )
{
// Prevent crash if battery was somehow removed.
if( !it->magazine_current() ) {
return 0;
}

if( t ) {
if( calendar::once_every( 1_minutes ) ) {
const SpeechBubble &speech = get_speech( "foodperson_mask" );
Expand Down

0 comments on commit 541150b

Please sign in to comment.