mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01: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:
parent
6991b2045d
commit
cf8442b12c
1 changed files with 12 additions and 0 deletions
|
@ -5,6 +5,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "UtilityClass.h"
|
||||||
|
|
||||||
binaryBlob::binaryBlob()
|
binaryBlob::binaryBlob()
|
||||||
{
|
{
|
||||||
numberofHeaders = 0;
|
numberofHeaders = 0;
|
||||||
|
@ -159,11 +161,21 @@ int binaryBlob::getIndex(const char* _name)
|
||||||
|
|
||||||
int binaryBlob::getSize(int _index)
|
int binaryBlob::getSize(int _index)
|
||||||
{
|
{
|
||||||
|
if (!INBOUNDS_ARR(_index, m_headers))
|
||||||
|
{
|
||||||
|
puts("getSize() out-of-bounds!");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return m_headers[_index].size;
|
return m_headers[_index].size;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* binaryBlob::getAddress(int _index)
|
char* binaryBlob::getAddress(int _index)
|
||||||
{
|
{
|
||||||
|
if (!INBOUNDS_ARR(_index, m_memblocks))
|
||||||
|
{
|
||||||
|
puts("getAddress() out-of-bounds!");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return m_memblocks[_index];
|
return m_memblocks[_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue