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

Fix seg fault when weapon is removed during attack #6816

Merged
merged 1 commit into from Jul 1, 2022

Conversation

mattsc
Copy link
Member

@mattsc mattsc commented Jun 30, 2022

Events during attacks may modify either of the units involved. If, as a result, one of the units does not have a weapon of the type used any more, this previously caused a segmentation fault in unit_attack() in udisplay.cpp. The solution is to set the remaining number of strikes for the unit to zero. This prevents that unit from striking again, but lets the opponent continue its attack.

I have confirmed that this fixes both #4927 and #5914. That's also the reason why this is based on 1.16, because the save provided in one of the issues is for 1.16. Obviously, if this is merged, it should be forward ported as well.

Events during attacks may modify either of the units involved. If, as a result, one of the units does not have a weapon of the type used any more, this previously caused a segmentation fault in unit_attack() in udisplay.cpp. The solution is to set the remaining number of strikes for the unit to zero. This prevents that unit from striking again, but lets the opponent continue its attack.

Fixes wesnoth#4927 and wesnoth#5914
@Wedge009 Wedge009 added Units Issues that involve unit definitions or their implementation in the engine. Fwdport A reminder of a bugfix that was added to the stable branch that needs to be duplicated on master. labels Jul 1, 2022
@mattsc mattsc merged commit a6bf253 into wesnoth:1.16 Jul 1, 2022
@mattsc mattsc deleted the fix_segfault_attack branch July 1, 2022 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fwdport A reminder of a bugfix that was added to the stable branch that needs to be duplicated on master. Units Issues that involve unit definitions or their implementation in the engine.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants