Merge pull request #210 from Nextra/destroy-invalid
Fix ArrayDestroy/DestroyStack erroring on invalid handle
This commit is contained in:
commit
3b16c6be92
|
@ -1,11 +1,11 @@
|
|||
// vim: set ts=4 sw=4 tw=99 noet:
|
||||
//
|
||||
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
||||
// Copyright (C) The AMX Mod X Development Team.
|
||||
//
|
||||
// This software is licensed under the GNU General Public License, version 3 or higher.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// https://alliedmods.net/amxmodx-license
|
||||
// vim: set ts=4 sw=4 tw=99 noet:
|
||||
//
|
||||
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
||||
// Copyright (C) The AMX Mod X Development Team.
|
||||
//
|
||||
// This software is licensed under the GNU General Public License, version 3 or higher.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// https://alliedmods.net/amxmodx-license
|
||||
|
||||
#include "amxmodx.h"
|
||||
#include "datastructs.h"
|
||||
|
@ -661,6 +661,12 @@ static cell AMX_NATIVE_CALL ArrayDeleteItem(AMX* amx, cell* params)
|
|||
static cell AMX_NATIVE_CALL ArrayDestroy(AMX* amx, cell* params)
|
||||
{
|
||||
cell* handle = get_amxaddr(amx, params[1]);
|
||||
|
||||
if (*handle == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
CellArray* vec = HandleToVector(amx, *handle);
|
||||
|
||||
if (vec == NULL)
|
||||
|
@ -720,11 +726,11 @@ static cell AMX_NATIVE_CALL ArraySort(AMX* amx, cell* params)
|
|||
char* funcName = get_amxstring(amx, params[2], 0, len);
|
||||
|
||||
// MySortFunc(Array:array, item1, item2, const data[], data_size)
|
||||
int func = registerSPForwardByName(amx, funcName, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
|
||||
if (func < 0)
|
||||
{
|
||||
LogError(amx, AMX_ERR_NATIVE, "The public function \"%s\" was not found.", funcName);
|
||||
return 0;
|
||||
int func = registerSPForwardByName(amx, funcName, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
|
||||
if (func < 0)
|
||||
{
|
||||
LogError(amx, AMX_ERR_NATIVE, "The public function \"%s\" was not found.", funcName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t arraysize = vec->size();
|
||||
|
|
|
@ -241,6 +241,12 @@ static cell AMX_NATIVE_CALL IsStackEmpty(AMX* amx, cell* params)
|
|||
static cell AMX_NATIVE_CALL DestroyStack(AMX* amx, cell* params)
|
||||
{
|
||||
cell *handle = get_amxaddr(amx, params[1]);
|
||||
|
||||
if (*handle == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
CellArray *vec = HandleToVector(amx, *handle);
|
||||
|
||||
if (vec == NULL)
|
||||
|
|
Loading…
Reference in New Issue
Block a user