Skip to content

Commit

Permalink
fix CreateEvent leak (#604)
Browse files Browse the repository at this point in the history
  • Loading branch information
number201724 authored Oct 6, 2024
1 parent 8a795de commit 49cc91e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/scripting/natives/natives_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ static IGameEvent *CreateEvent(ScriptContext &script_context) {
bool force = script_context.GetArgument<bool>(1);

auto pEvent = globals::gameEventManager->CreateEvent(name, force);
managed_game_events.push_back(pEvent);

if (pEvent != nullptr) {
managed_game_events.push_back(pEvent);
}

return pEvent;
}
Expand Down Expand Up @@ -301,4 +304,4 @@ REGISTER_NATIVES(events, {
ScriptEngine::RegisterNativeHandler("LOAD_EVENTS_FROM_FILE", LoadEventsFromFile);
})

} // namespace counterstrikesharp
} // namespace counterstrikesharp

0 comments on commit 49cc91e

Please sign in to comment.