mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
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:
|
// vim: set ts=4 sw=4 tw=99 noet:
|
||||||
//
|
//
|
||||||
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
||||||
// Copyright (C) The AMX Mod X Development Team.
|
// Copyright (C) The AMX Mod X Development Team.
|
||||||
//
|
//
|
||||||
// This software is licensed under the GNU General Public License, version 3 or higher.
|
// 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:
|
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||||
// https://alliedmods.net/amxmodx-license
|
// https://alliedmods.net/amxmodx-license
|
||||||
|
|
||||||
#include "amxmodx.h"
|
#include "amxmodx.h"
|
||||||
#include "datastructs.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)
|
static cell AMX_NATIVE_CALL ArrayDestroy(AMX* amx, cell* params)
|
||||||
{
|
{
|
||||||
cell* handle = get_amxaddr(amx, params[1]);
|
cell* handle = get_amxaddr(amx, params[1]);
|
||||||
|
|
||||||
|
if (*handle == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
CellArray* vec = HandleToVector(amx, *handle);
|
CellArray* vec = HandleToVector(amx, *handle);
|
||||||
|
|
||||||
if (vec == NULL)
|
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);
|
char* funcName = get_amxstring(amx, params[2], 0, len);
|
||||||
|
|
||||||
// MySortFunc(Array:array, item1, item2, const data[], data_size)
|
// 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);
|
int func = registerSPForwardByName(amx, funcName, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
|
||||||
if (func < 0)
|
if (func < 0)
|
||||||
{
|
{
|
||||||
LogError(amx, AMX_ERR_NATIVE, "The public function \"%s\" was not found.", funcName);
|
LogError(amx, AMX_ERR_NATIVE, "The public function \"%s\" was not found.", funcName);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t arraysize = vec->size();
|
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)
|
static cell AMX_NATIVE_CALL DestroyStack(AMX* amx, cell* params)
|
||||||
{
|
{
|
||||||
cell *handle = get_amxaddr(amx, params[1]);
|
cell *handle = get_amxaddr(amx, params[1]);
|
||||||
|
|
||||||
|
if (*handle == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
CellArray *vec = HandleToVector(amx, *handle);
|
CellArray *vec = HandleToVector(amx, *handle);
|
||||||
|
|
||||||
if (vec == NULL)
|
if (vec == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user