Skip to content

Commit

Permalink
Merge pull request #51 from leHeix/master
Browse files Browse the repository at this point in the history
Fix fakeQuat memory leak
  • Loading branch information
ADRFranklin authored Sep 27, 2021
2 parents 1056c0a + 72cf789 commit 5dfd83d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,5 @@ void InstallPreHooks()
{
std::memset(&Player::fakeHealth, 255, sizeof(Player::fakeHealth));
std::memset(&Player::fakeArmour, 255, sizeof(Player::fakeArmour));

for (int i = 0; i < 1000; i++)
{
Player::fakeQuat[i] = 0;
}
std::memset(&Player::fakeQuat[0], NULL, sizeof(Player::fakeQuat));
}
7 changes: 6 additions & 1 deletion src/Scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,14 @@ static cell AMX_NATIVE_CALL SetFakeFacingAngle(AMX *amx, cell *params)
if(!IsPlayerConnected(playerid))
return 0;

if (Player::fakeQuat[playerid])
{
delete Player::fakeQuat[playerid];
}

if ((int)params[2] == 0x7FFFFFFF)
{
Player::fakeQuat[playerid] = NULL;
Player::fakeQuat[playerid] = nullptr;
}
else
{
Expand Down

0 comments on commit 5dfd83d

Please sign in to comment.