Skip to content

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