sna: Validate that the reg/insn size is well defined

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2014-12-01 14:26:46 +00:00
parent 263d109986
commit 9c2c485df9
1 changed files with 7 additions and 0 deletions

View File

@ -34,6 +34,8 @@
#include <string.h>
#include <stdlib.h>
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
/***********************************************************************
* Internal helper for constructing instructions
*/
@ -179,6 +181,11 @@ validate_reg(struct brw_instruction *insn, struct brw_reg reg)
reg.file == BRW_ARF_NULL)
return;
assert(reg.hstride >= 0 && reg.hstride < ARRAY_SIZE(hstride_for_reg));
assert(reg.vstride >= 0 && reg.vstride < ARRAY_SIZE(vstride_for_reg));
assert(reg.width >= 0 && reg.width < ARRAY_SIZE(width_for_reg));
assert(insn->header.execution_size >= 0 && insn->header.execution_size < ARRAY_SIZE(execsize_for_reg));
hstride = hstride_for_reg[reg.hstride];
if (reg.vstride == 0xf) {