ValveSoftware / source-sdk-2013

The 2013 edition of the Source SDK
https://developer.valvesoftware.com/wiki/SDK2013_GettingStarted
Other
3.73k stars 1.99k forks source link

Some container classes do not copy construct/move when copying containers/elements #410

Open SamVanheer opened 7 years ago

SamVanheer commented 7 years ago

Some container classes do not use a type's copy or move constructor/operator when copying or moving containers or elements. For instance, CUtlRBTree's CopyFrom method memcpys the data instead of properly copying it. If the type in question were to contain managed memory, like CUtlString manages a char*, it will double free the memory, and may prematurely free the memory as well.

All containers should invoke the copy/move constructor/operator when initializing memory with another instance of a type, or at least warn in comments when it isn't supported.

Note that CUtlRBTree is used by CUtlMap, which is used by CUtlDict. This problem cascades into all dependent container classes.