intel: Assert that relocation offsets are within the target
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 2 Oct 2009 18:46:03 +0000 (19:46 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Sat, 3 Oct 2009 22:06:39 +0000 (23:06 +0100)
This should catch the common programming error where we attempt to
emit a relocation to beyond the end of the target buffer.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
src/mesa/drivers/dri/intel/intel_batchbuffer.h

index 51579df09e771a9750cedaa0520378577ee78101..9a619fbd5cfdf771371d42f5e0d43e5ad4cc00d8 100644 (file)
@@ -157,7 +157,7 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
 #define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d)
 
 #define OUT_RELOC(buf, read_domains, write_domain, delta) do {         \
-   assert((delta) >= 0);                                               \
+   assert((unsigned) (delta) <= buf->size);                            \
    intel_batchbuffer_emit_reloc(intel->batch, buf,                     \
                                read_domains, write_domain, delta);     \
 } while (0)