FreakFortressBat icon indicating copy to clipboard operation
FreakFortressBat copied to clipboard

[Bug] Invalid timer at delete MusicTimer[client]

Open bottiger1 opened this issue 2 years ago • 2 comments

Description

Not sure how this happened, but the plugin tried to close an invalid timer on setup. And it stops the boss from ever being selected.

L 05/03/2022 - 20:33:03: [SM] Exception reported: Handle 53810b17 is invalid (error 3) L 05/03/2022 - 20:33:03: [SM] Blaming: freak_fortress_2.smx L 05/03/2022 - 20:33:03: [SM] Call stack trace: L 05/03/2022 - 20:33:03: [SM] [0] CloseHandle L 05/03/2022 - 20:33:03: [SM] [1] Line 5502, Unofficial Freak Fortress::StopMusic L 05/03/2022 - 20:33:03: [SM] [2] Line 3706, Unofficial Freak Fortress::OnRoundSetup

Reproduce

No idea how to reproduce

Recommendations

I recommend some code cleanup to try to prevent this from happening.

  • Check if the timer is null before deleting

https://github.com/Batfoxkid/FreakFortressBat/blob/391af29d7944b19203992d3ca46fd9abafaee095/addons/sourcemod/scripting/impl/music.sp#L7

  • Check if timer is null first and delete first

https://github.com/Batfoxkid/FreakFortressBat/blob/391af29d7944b19203992d3ca46fd9abafaee095/addons/sourcemod/scripting/impl/music.sp#L132

  • Set the variable to null here after these lines. KillTimer does not set the variable to null, unlike delete.

https://github.com/Batfoxkid/FreakFortressBat/blob/f07988f2d5cfc88401f8add75060feaafc1b4503/addons/sourcemod/scripting/impl/panels.sp#L1269

https://github.com/Batfoxkid/FreakFortressBat/blob/f07988f2d5cfc88401f8add75060feaafc1b4503/addons/sourcemod/scripting/impl/panels.sp#L1282

These lines are the only places I could find that could be an issue, but there could be more.

bottiger1 avatar May 04 '22 05:05 bottiger1

i believe delete checks if Handle is null before closing it

MAGNAT2645 avatar May 04 '22 12:05 MAGNAT2645

Update:

For this line, it should check if client is 0. And outside the if statement it should set the musictimer to null.

MusicTimer[client] = null;

https://github.com/Batfoxkid/FreakFortressBat/blob/391af29d7944b19203992d3ca46fd9abafaee095/addons/sourcemod/scripting/impl/music.sp#L7

bottiger1 avatar May 04 '22 18:05 bottiger1