Added guards around DemHandlers functions
This commit is contained in:
parent
b67f448d18
commit
9ad7c54510
@ -23,23 +23,39 @@ typedef bool (*DemMsgJsonWriteFn)(JsonWrite& jsonbuf, void* data);
|
|||||||
bool DemHandlers::DemMsg_FileRead(uint32_t type, FileRead& demofile, void* data)
|
bool DemHandlers::DemMsg_FileRead(uint32_t type, FileRead& demofile, void* data)
|
||||||
{
|
{
|
||||||
static const DemMsgFileReadFn demHandlers[] = DECLARE_DEM_HANDLER_ARRAY(FileRead);
|
static const DemMsgFileReadFn demHandlers[] = DECLARE_DEM_HANDLER_ARRAY(FileRead);
|
||||||
|
if (type >= (sizeof(demHandlers) / sizeof(DemMsgFileReadFn)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return demHandlers[type](demofile, data);
|
return demHandlers[type](demofile, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DemHandlers::DemMsg_FileWrite(uint32_t type, FileWrite& demofile, void* data)
|
bool DemHandlers::DemMsg_FileWrite(uint32_t type, FileWrite& demofile, void* data)
|
||||||
{
|
{
|
||||||
static const DemMsgFileWriteFn demHandlers[] = DECLARE_DEM_HANDLER_ARRAY(FileWrite);
|
static const DemMsgFileWriteFn demHandlers[] = DECLARE_DEM_HANDLER_ARRAY(FileWrite);
|
||||||
|
if (type >= (sizeof(demHandlers) / sizeof(DemMsgFileWriteFn)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return demHandlers[type](demofile, data);
|
return demHandlers[type](demofile, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DemHandlers::DemMsg_JsonRead(uint32_t type, JsonRead& jsonbuf, void* data)
|
bool DemHandlers::DemMsg_JsonRead(uint32_t type, JsonRead& jsonbuf, void* data)
|
||||||
{
|
{
|
||||||
static const DemMsgJsonReadFn demHandlers[] = DECLARE_DEM_HANDLER_ARRAY(JsonRead);
|
static const DemMsgJsonReadFn demHandlers[] = DECLARE_DEM_HANDLER_ARRAY(JsonRead);
|
||||||
|
if (type >= (sizeof(demHandlers) / sizeof(DemMsgJsonReadFn)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return demHandlers[type](jsonbuf, data);
|
return demHandlers[type](jsonbuf, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DemHandlers::DemMsg_JsonWrite(uint32_t type, JsonWrite& jsonbuf, void* data)
|
bool DemHandlers::DemMsg_JsonWrite(uint32_t type, JsonWrite& jsonbuf, void* data)
|
||||||
{
|
{
|
||||||
static const DemMsgJsonWriteFn demHandlers[] = DECLARE_DEM_HANDLER_ARRAY(JsonWrite);
|
static const DemMsgJsonWriteFn demHandlers[] = DECLARE_DEM_HANDLER_ARRAY(JsonWrite);
|
||||||
|
if (type >= (sizeof(demHandlers) / sizeof(DemMsgJsonWriteFn)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return demHandlers[type](jsonbuf, data);
|
return demHandlers[type](jsonbuf, data);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user