Avoid array overflow

with fuzzed source code we might run into this with idx out of bounds.
We're going to error out on this later, but let's not access
out-of-bounds elements.
This commit is contained in:
Michael Matz 2021-02-12 23:46:21 +01:00
parent c4ae326a1d
commit ce8814cdd6

View file

@ -735,7 +735,7 @@ static int arg_prepare_reg(int idx) {
/* idx=0: r10, idx=1: r11 */
return idx + 10;
else
return arg_regs[idx];
return idx >= 0 && idx < REGN ? arg_regs[idx] : 0;
}
/* Generate function call. The function address is pushed first, then
@ -1221,7 +1221,7 @@ static int arg_prepare_reg(int idx) {
/* idx=2: r10, idx=3: r11 */
return idx + 8;
else
return arg_regs[idx];
return idx >= 0 && idx < REGN ? arg_regs[idx] : 0;
}
/* Generate function call. The function address is pushed first, then