1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-02 11:03:32 +02:00

Add bounds checks to getSize() and getAddress()

It's all too easy for someone to pass in a bad index and index out of
bounds, so we need to prevent that from happening.
This commit is contained in:
Misa 2020-08-14 01:54:19 -07:00 committed by Ethan Lee
parent 6991b2045d
commit cf8442b12c

View File

@ -5,6 +5,8 @@
#include <stdio.h>
#include <stdlib.h>
#include "UtilityClass.h"
binaryBlob::binaryBlob()
{
numberofHeaders = 0;
@ -159,11 +161,21 @@ int binaryBlob::getIndex(const char* _name)
int binaryBlob::getSize(int _index)
{
if (!INBOUNDS_ARR(_index, m_headers))
{
puts("getSize() out-of-bounds!");
return 0;
}
return m_headers[_index].size;
}
char* binaryBlob::getAddress(int _index)
{
if (!INBOUNDS_ARR(_index, m_memblocks))
{
puts("getAddress() out-of-bounds!");
return NULL;
}
return m_memblocks[_index];
}