Skip to content

Commit

Permalink
Fix legit (?) cases of use-after-move
Browse files Browse the repository at this point in the history
  • Loading branch information
olanti-p committed Nov 3, 2023
1 parent c78faaf commit 6d79737
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/magic_spell_effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,8 @@ void spell_effect::spawn_ethereal_item( const spell &sp, Creature &caster, const
} else {
you.i_add( std::move( granted ) );
}
if( !granted->count_by_charges() ) {
// NOLINTNEXTLINE(bugprone-use-after-move)
if( granted && !granted->count_by_charges() ) {
for( int i = 1; i < sp.damage(); i++ ) {
you.i_add( item::spawn( as_item ) );
}
Expand Down
3 changes: 2 additions & 1 deletion tests/basecamp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ static detached_ptr<item> make_food( const itype_id &inner_food_id, int amount,
can = item::spawn( unsealed_can_id, calendar::turn_zero );
break;
}
REQUIRE( can->contents.insert_item( std::move( food ) ).success() );
ret_val<bool> retval = can->contents.insert_item( std::move( food ) );
REQUIRE( retval.success() );
return can;
}

Expand Down

0 comments on commit 6d79737

Please sign in to comment.