- Added a crash protection in case mapfreeblock unlock tries to free a null pointer.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@8688 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
skotlex 2006-09-09 17:32:40 +00:00
parent 2487548c72
commit e232baea00
2 changed files with 4 additions and 1 deletions

View File

@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/09/09 2006/09/09
* Added a crash protection in case mapfreeblock unlock tries to free a null
pointer. [Skotlex]
* Moved perfect_hiding from state to special_state, so that it clears out * Moved perfect_hiding from state to special_state, so that it clears out
when you remove your pet. [Skotlex] when you remove your pet. [Skotlex]
* Probably fixed the Taekwon Rest skills. [Skotlex] * Probably fixed the Taekwon Rest skills. [Skotlex]

View File

@ -271,6 +271,7 @@ unsigned int distance(int dx, int dy) {
*/ */
int map_freeblock (struct block_list *bl) int map_freeblock (struct block_list *bl)
{ {
nullpo_retr(block_free_lock, bl);
if (block_free_lock == 0 || block_free_count >= block_free_max) if (block_free_lock == 0 || block_free_count >= block_free_max)
{ {
aFree(bl); aFree(bl);
@ -308,7 +309,7 @@ int map_freeblock_unlock_sub(char *file, int lineno)
{ //Directly calling aFree shouldn't be a leak, as Free remembers the size the original pointed to memory was allocated with? [Skotlex] { //Directly calling aFree shouldn't be a leak, as Free remembers the size the original pointed to memory was allocated with? [Skotlex]
// aFree(block_free[i]); // aFree(block_free[i]);
// _mfree(block_free[i], file, lineno, __func__); // _mfree(block_free[i], file, lineno, __func__);
_mfree(block_free[i], file, block_free[i]->type*100000+lineno, __func__); _mfree(block_free[i], file, ((block_free[i]?block_free[i]->type:0)*100000)+lineno, __func__);
block_free[i] = NULL; block_free[i] = NULL;
} }
block_free_count = 0; block_free_count = 0;