10.07.2012, 00:26
(
Последний раз редактировалось cyber_punk; 11.07.2012 в 19:53.
)
I got a bot attack on my server, not sure how the hell they got around needing a player name to connect but I ended up discovering a run time error with the way map functions are scripted in this. The error would terminate the server which sucks. I have it fixed though.
The error: terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid
So if you went to add a key that was null/empty it would pop that. Like I said under normal conditions this would not happen but with the attack I had the player name was empty and passed on to the map_insert function. The fix is just to set the char array to a default value of NULL then checking after using amx_StrParam to make sure there is a valid string (not NULL).
I also fixed map_remove which would crash a server if you tried to remove a key that did not exist in the map.
Just a tip you can save performance by not using map_contains before map_get functions. Just check that the returned value is not -1. The get functions have a built in check to see if they are contained in the map.
Just download the attached zip and compile. If you have or find any issues just report them and I will see what I can do.
The error: terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid
So if you went to add a key that was null/empty it would pop that. Like I said under normal conditions this would not happen but with the attack I had the player name was empty and passed on to the map_insert function. The fix is just to set the char array to a default value of NULL then checking after using amx_StrParam to make sure there is a valid string (not NULL).
I also fixed map_remove which would crash a server if you tried to remove a key that did not exist in the map.
Just a tip you can save performance by not using map_contains before map_get functions. Just check that the returned value is not -1. The get functions have a built in check to see if they are contained in the map.
Just download the attached zip and compile. If you have or find any issues just report them and I will see what I can do.