mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
DIRECTOR: LINGO: Added helper macro for array bounds check
This commit is contained in:
parent
94b7e15d72
commit
ac1220c16e
@ -52,6 +52,12 @@ namespace Director {
|
||||
return; \
|
||||
}
|
||||
|
||||
#define ARRBOUNDSCHECK(idx,array) \
|
||||
if ((idx)-1 < 0 || (idx) > (array).u.farr->size()) { \
|
||||
warning("%s: index out of bounds (%d of %d)", __FUNCTION__, (idx), (array).u.farr->size()); \
|
||||
return; \
|
||||
}
|
||||
|
||||
static struct BuiltinProto {
|
||||
const char *name;
|
||||
void (*func)(int);
|
||||
@ -645,11 +651,7 @@ void LB::b_getAt(int nargs) {
|
||||
|
||||
TYPECHECK(index, INT);
|
||||
TYPECHECK(list, ARRAY);
|
||||
|
||||
if (index.u.i-1 < 0 || index.u.i > list.u.farr->size()){
|
||||
warning("b_getAt: index %s out of bounds", index.type2str());
|
||||
return;
|
||||
}
|
||||
ARRBOUNDSCHECK(index.u.i, list);
|
||||
|
||||
Datum result = list.u.farr->operator[](index.u.i-1);
|
||||
g_lingo->push(result);
|
||||
|
Loading…
Reference in New Issue
Block a user