Skip to content

Fix heap corruption in CUtlVector destructor#1165

Merged
Headline merged 2 commits intoalliedmodders:masterfrom
peace-maker:fuzzymap_heapcrt
Feb 8, 2020
Merged

Fix heap corruption in CUtlVector destructor#1165
Headline merged 2 commits intoalliedmodders:masterfrom
peace-maker:fuzzymap_heapcrt

Conversation

@peace-maker
Copy link
Member

CHalfLife2::FindMap works around the missing IVEngineServer::FindMap function by using the command autocompletion feature of the changelevel command.

The function populates a CUtlVector<CUtlString> object with the auto completion results. The game allocates memory for the vector and strings and we try to free it. This crashes when the C Run-time library version differs, which can happen when compiling using a newer toolchain.

Fixes #910 like @psychonic suggested.

I've only tested this on CS:GO Windows. This allowed me to run my server with a self-compiled build of SourceMod.

`CHalfLife2::FindMap` works around the missing `IVEngineServer::FindMap` function by using the command autocompletion feature of the `changelevel` command.

The function populates a `CUtlVector<CUtlString>` object with the auto completion results. The game allocates memory for the vector and strings and we try to free it. This crashes when the C Run-time library version differs.

Fixes alliedmodders#910 like @psychonic suggested.
@peace-maker
Copy link
Member Author

Hm, looks like CUtlMemory::Detach only appears in CSGO's sdk. This would need some really ugly hacks or changes to the other sdks.

Looks like only hl2sdk-csgo has `CUtlMemory::Detach()`, so try not use it for other games like l4d.
@peace-maker
Copy link
Member Author

Ok, looks like I can reuse the existing shims for CUtlString 😄

Copy link
Member

@Headline Headline left a comment

Choose a reason for hiding this comment

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

This looks good, PM.

Thanks a ton ❤️

🚢

@Headline Headline merged commit 739c07c into alliedmodders:master Feb 8, 2020
@peace-maker peace-maker deleted the fuzzymap_heapcrt branch February 8, 2020 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CS:GO Server Crash w/ fuzzy map names & self-compiled SM

2 participants