summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2007-05-21 13:06:12 -0700
committerEric Anholt <eric@anholt.net>2007-05-21 13:06:12 -0700
commitb1fcabefa2f3fa81a20c1556383458315bb49bbf (patch)
treed09b110ab24e69482d5ca6db9c5287b2122317f0
parentb0b84529cf1d61d3a53d402f039b442260788624 (diff)
Don't read beyond the end of the buffer with INTEL_DEBUG=bat.
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_batchbuffer.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c
index 67fca371a7..42ec0ae980 100644
--- a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c
@@ -67,13 +67,23 @@
*/
static void
-intel_dump_batchbuffer(GLuint offset, GLuint * ptr, GLuint count)
+intel_dump_batchbuffer(GLuint offset, GLuint * ptr, GLuint size)
{
int i;
- fprintf(stderr, "\n\n\nSTART BATCH (%d dwords):\n", count / 4);
- for (i = 0; i < count / 4; i += 4)
- fprintf(stderr, "0x%x:\t0x%08x 0x%08x 0x%08x 0x%08x\n",
- offset + i * 4, ptr[i], ptr[i + 1], ptr[i + 2], ptr[i + 3]);
+ fprintf(stderr, "\n\n\nSTART BATCH (%d dwords):\n", size / 4);
+ for (i = 0; i < size / 4; i += 4) {
+ char dw1[11], dw2[11] = "", dw3[11] = "", dw4[11] = "";
+
+ sprintf(dw1, "0x%08x", ptr[i]);
+ if (i + 1 < size / 4)
+ sprintf(dw2, "0x%08x", ptr[i + 1]);
+ if (i + 2 < size / 4)
+ sprintf(dw3, "0x%08x", ptr[i + 2]);
+ if (i + 3 < size / 4)
+ sprintf(dw4, "0x%08x", ptr[i + 3]);
+ fprintf(stderr, "0x%x:\t%s %s %s %s\n", offset + i * 4,
+ dw1, dw2, dw3, dw4);
+ }
fprintf(stderr, "END BATCH\n\n\n");
}