loot / libloot

A C++ library for accessing LOOT's metadata and sorting functionality.
GNU General Public License v3.0
32 stars 12 forks source link

Undefined behaviour if a DatabaseInterface pointer is used after discarding its creator GameInterface #6

Closed Ortham closed 7 years ago

Ortham commented 7 years ago

A DatabaseInterface (implementation) keeps a reference to the GameInterface (implementation) it was created for, so if the latter is destroyed, the former enters an invalid state, leading to undefined behaviour. I encountered this while trying to adapt the python wrapper with minimal breaking changes (I had a function that constructs a local game handle and returns its database).

The implementations should be refactored so that there is no storage of a Game object in the ApiDatabase object, or if an object is stored, it should be in a smart pointer.

Ortham commented 7 years ago

Fixed as of 93b878a2fc1c8f1c61b5aa98a3119e3463fd8f00.