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 possible segfault caused by #2468 when guns are fired #2516

Merged
merged 2 commits into from
Mar 31, 2023

Conversation

KheirFerrum
Copy link
Collaborator

@KheirFerrum KheirFerrum commented Mar 31, 2023

Summary

SUMMARY: Bugfixes "Fix possible segfault caused by #2468 when guns are fired."

Purpose of change

Fixes #2512

#2468 has an apparent issue due to how I structured an if block. Fix that ASAP.

Basically, if the gun doesn't use ammo, it will still try to check the amount of ammo passed by the ammo item_location, which will lead to a null reference that crashes the game.

Describe the solution

Restructures it so it doesn't route through ammo.get_item()->count() unless the item actually exists.

Describe alternatives you've considered

Testing

Fire A7 laser rifle, it doesn't crash.

Additional context

I'm an idiot and I should've playtested this a lot fucking more.

Fix dumb code I made
@github-actions github-actions bot added the src changes related to source code. label Mar 31, 2023
@scarf005 scarf005 self-requested a review March 31, 2023 13:45
Copy link
Member

@scarf005 scarf005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

spawned UPS and A7 laser rifle, they fire without segfault. i'll review rest of the code after.

src/ranged.cpp Outdated Show resolved Hide resolved
Co-authored-by: scarf <greenscarf005@gmail.com>
@scarf005 scarf005 merged commit 9fc83b6 into cataclysmbnteam:upload Mar 31, 2023
@KheirFerrum KheirFerrum deleted the fire_gun-fix branch March 31, 2023 20:27
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.

Game keeps crashing when trying to fire a turret from vehicle
2 participants