mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 18:52:07 +00:00
Fix array overflow on invalid macro arg evaluation
`macro_GetArg` had not been changed after the previous commit; however, the old code relied on the `macroArgs->args` array being at least `MAXMACROARGS` entries large (which was the case until the last commit). The boundary against which it checked would have better been written as `sizeof(macroArgs->args)/sizeof(macroArgs->args[0])`, I guess, but what's done is done.
This commit is contained in:
@@ -64,7 +64,8 @@ char const *macro_GetArg(uint32_t i)
|
||||
{
|
||||
uint32_t realIndex = i + macroArgs->shift - 1;
|
||||
|
||||
return realIndex >= MAXMACROARGS ? NULL : macroArgs->args[realIndex];
|
||||
return realIndex >= macroArgs->nbArgs ? NULL
|
||||
: macroArgs->args[realIndex];
|
||||
}
|
||||
|
||||
uint32_t macro_GetUniqueID(void)
|
||||
|
||||
Reference in New Issue
Block a user