From: Eric Anholt Date: Mon, 21 May 2007 20:06:12 +0000 (-0700) Subject: Don't read beyond the end of the buffer with INTEL_DEBUG=bat. X-Git-Tag: 062012170305~19325^2~31^2~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b1fcabefa2f3fa81a20c1556383458315bb49bbf;p=profile%2Fivi%2Fmesa.git Don't read beyond the end of the buffer with INTEL_DEBUG=bat. --- diff --git a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c index 67fca37..42ec0ae 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"); }