Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed segfault caused by attitude check when monster shooting vehicle #3136

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

Vollch
Copy link
Contributor

@Vollch Vollch commented Sep 13, 2023

Summary

SUMMARY: Bugfixes "Fixed segfault caused by attitude check when monster shooting vehicle"

Purpose of change

When monster target_moving_vehicles it legitimely have nullptr target, and those untargeted shoots cause segfault due to friendliness check.

Describe the solution

Added null check.

Describe alternatives you've considered

Pointing author at issue so i don't need to fill exhausting surveys.

Testing

Loaded bugged save, no more crashes.

Additional context

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ff611faf9fc in monster::attitude_to (this=0x31d32840, other=...) at src/monster.cpp:1047
1047        const monster *m = other.is_monster() ? static_cast< const monster *>( &other ) : nullptr;
(gdb) p other
$1 = (const Creature &) <error reading variable: Cannot access memory at address 0x0>
(gdb) bt
#0  0x00007ff611faf9fc in monster::attitude_to (this=0x31d32840, other=...) at src/monster.cpp:1047
#1  0x00007ff611e9a0e0 in gun_actor::call (this=0x18d912e0, z=...) at src/mattack_actors.cpp:585
#2  0x00007ff611f976c7 in monster::move (this=0x31d32840) at src/monmove.cpp:751
#3  0x00007ff611a01f8b in game::monmove (this=0x914bd10) at src/game.cpp:4125
#4  0x00007ff6119eb6d9 in game::do_turn (this=0x914bd10) at src/game.cpp:1505
#5  0x00007ff611d87951 in main (argc=0, argv=0xb1fb8) at src/main.cpp:764
(gdb) f 1
#1  0x00007ff611e9a0e0 in gun_actor::call (this=0x18d912e0, z=...) at src/mattack_actors.cpp:585
585         if( z.attitude_to( *target ) == Creature::A_FRIENDLY ) {
(gdb) p untargeted
$2 = true
(gdb) p target_moving_vehicles
$3 = true

@github-actions github-actions bot added the src changes related to source code. label Sep 13, 2023
@chaosvolt chaosvolt merged commit 3e29ce6 into cataclysmbnteam:upload Sep 13, 2023
16 checks passed
@Vollch Vollch deleted the segfault branch September 13, 2023 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants