Several things:
1. While it's good that you've taken initiative to fix this bug, a full bug report is still needed - particularly testable samples to verify the bug itself and verify the fix. Please see
here. You did good in at least articulating what is going on, though, so that's good. Kudos for that.
2. Is this repairing code you've personally submitted previously? (Doesn't make much difference in this case, but it does help, at least for me, personally, to know)
3. Lastly, how long has the bug been present in GZDoom? If this bug has endured at least one release cycle, then we should expect that mods may have already been made which expect this buggy behavior. "Fixing" it may require a version check, depending on how widespread the use of this function is. This particular caveat applies because it affects how mods function - but if, as you say, the function was too unpredictable, anyway, then this issue might not apply.