Skip to content

Commit

Permalink
Declare a variable at the beginning to be in scope of original functi…
Browse files Browse the repository at this point in the history
…on and .c_str() wouldn't be a dangling pointer at that point

I didn't immediately release that the result was a dangling pointer, the life of which ended at the end of the condition

Of course, since we didn't allocate memory to it, after the original function is called it will still be freed, but it seems that the engine no longer uses this pointer too, and therefore we don't seem to need to store it.... So even if then it will be dangling, then specifically with this function it should not cause some issues after its call
  • Loading branch information
SmileyAG committed Mar 15, 2024
1 parent 4c8a6d8 commit 799b74c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion BunnymodXT/modules/HwDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8075,6 +8075,7 @@ HOOK_DEF_0(HwDLL, qboolean, __cdecl, CL_ReadDemoMessage_OLD)
HOOK_DEF_1(HwDLL, void, __cdecl, LoadThisDll, const char*, szDllFilename)
{
auto oldszDllFilename = szDllFilename;
std::string newszDllFilename;

if (boost::ends_with(szDllFilename, "metamod" DLL_EXTENSION))
{
Expand All @@ -8092,7 +8093,8 @@ HOOK_DEF_1(HwDLL, void, __cdecl, LoadThisDll, const char*, szDllFilename)
#endif

EngineDevMsg("[hw dll] Old path to game library: %s\n", szDllFilename);
szDllFilename = helper_functions::swap_lib(szDllFilename, cs_lib, "addons").c_str();
newszDllFilename = helper_functions::swap_lib(szDllFilename, cs_lib, "addons");
szDllFilename = newszDllFilename.c_str();
EngineDevMsg("[hw dll] New path to game library: %s\n", szDllFilename);

if (!strcmp(szDllFilename, oldszDllFilename))
Expand Down

0 comments on commit 799b74c

Please sign in to comment.