summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-11-04 15:57:24 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2011-11-04 18:12:38 +0000
commit573b23c6b618af808d3236395bbf4f4993b406e5 (patch)
tree7afcd56fb9011a3bf153fd31d4b06d797469d595
parent4ba55c3d110ba51400a72da7d4f4c62efcea1335 (diff)
sna: Add some asserts to detect buffer overflow.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_render_inline.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/sna/sna_render_inline.h b/src/sna/sna_render_inline.h
index f05063df..8ad755c1 100644
--- a/src/sna/sna_render_inline.h
+++ b/src/sna/sna_render_inline.h
@@ -23,11 +23,13 @@ static inline int vertex_space(struct sna *sna)
}
static inline void vertex_emit(struct sna *sna, float v)
{
+ assert(sna->render.vertex_used < ARRAY_SIZE(sna->render.vertex_data));
sna->render.vertex_data[sna->render.vertex_used++] = v;
}
static inline void vertex_emit_2s(struct sna *sna, int16_t x, int16_t y)
{
int16_t *v = (int16_t *)&sna->render.vertex_data[sna->render.vertex_used++];
+ assert(sna->render.vertex_used <= ARRAY_SIZE(sna->render.vertex_data));
v[0] = x;
v[1] = y;
}
@@ -50,6 +52,7 @@ static inline int batch_space(struct sna *sna)
static inline void batch_emit(struct sna *sna, uint32_t dword)
{
+ assert(sna->kgem.nbatch < sna->kgem.surface);
sna->kgem.batch[sna->kgem.nbatch++] = dword;
}