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 crash when NPC gives player equipment #39238

Merged
merged 1 commit into from
Apr 4, 2020

Conversation

Qrox
Copy link
Contributor

@Qrox Qrox commented Apr 4, 2020

Summary

SUMMARY: Bugfixes "Fix crash when NPC gives player equipment"

Purpose of change

Fixes #39186. According to the crash log the pure virtual function handler was called. Since the related classes do not call any virtual functions in their ctor or dtor the problem was probably a use-after-free. And it turned out that the code to randomly select an item from NPC inventory erases an item even if it's the selected item.

Describe the solution

Do not erase the selected item.

Testing

Debug spawned a few NPCs, traded with them so their inventory contains only two items, and modified their owed status to a high positive number so they were willing to share, and asked them to share equipment. The game no longer crashed after the fix.

@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` NPC / Factions NPCs, AI, Speech, Factions, Ownership labels Apr 4, 2020
@ZhilkinSerg ZhilkinSerg merged commit 224bfe5 into CleverRaven:master Apr 4, 2020
@Qrox Qrox deleted the fix-crash-39186 branch April 4, 2020 12:42
@Qrox Qrox mentioned this pull request Apr 9, 2020
@Qrox Qrox mentioned this pull request Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` NPC / Factions NPCs, AI, Speech, Factions, Ownership
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash on intimidating NPC 0.E
2 participants