Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix amx_Allot trying to access invalid memory when data size is higher than amx STK size #819

Merged
merged 6 commits into from
Dec 29, 2023

Conversation

AmyrAhmady
Copy link
Member

@AmyrAhmady AmyrAhmady commented Dec 28, 2023

This PR prevents server from crashing when amx_Allot wrongfully returns AMX_ERR_NONE and servers thinks it was successful when data size is higher than STK size, by simply returning AMX_ERR_MEMORY on when that situation happens and also printing a message about it, while hinting the user what they can do to fix it in their pawn code.

Example:

[2023-12-28T19:13:21+0330] [Error] Unable to find enough memory for your data.
[2023-12-28T19:13:21+0330] [Error] Size: 4195184 bytes, Available space: 17256 bytes, Need extra size: 4177928 bytes
[2023-12-28T19:13:21+0330] [Error] You can increase your available memory size by using `#pragma dynamic 1048796`.
[2023-12-28T19:13:21+0330] [Error] Out of memory

Server/Components/Pawn/Script/Script.cpp Outdated Show resolved Hide resolved
Server/Components/Pawn/Script/Script.cpp Outdated Show resolved Hide resolved
@AmyrAhmady AmyrAhmady requested a review from Hual December 29, 2023 16:49
@AmyrAhmady AmyrAhmady merged commit ebb13f6 into master Dec 29, 2023
14 checks passed
@AmyrAhmady AmyrAhmady deleted the amir/prevent-crash-amx_Allot branch December 29, 2023 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants