Mesa (master): i965: Initialize new chunks of realloc'd memory.

Matt Turner mattst88 at kemper.freedesktop.org
Tue Jul 15 17:11:39 UTC 2014


Module: Mesa
Branch: master
Commit: 76caaedd7e6b5c9e1c3b4c951d5820df9f419228
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=76caaedd7e6b5c9e1c3b4c951d5820df9f419228

Author: Matt Turner <mattst88 at gmail.com>
Date:   Tue Jul  8 16:50:28 2014 -0700

i965: Initialize new chunks of realloc'd memory.

Otherwise we'd compare uninitialized pointers with NULL and dereference,
leading to crashes.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/drivers/dri/i965/intel_asm_annotation.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/intel_asm_annotation.c b/src/mesa/drivers/dri/i965/intel_asm_annotation.c
index 4717baf..6a51d89 100644
--- a/src/mesa/drivers/dri/i965/intel_asm_annotation.c
+++ b/src/mesa/drivers/dri/i965/intel_asm_annotation.c
@@ -96,11 +96,15 @@ void annotate(struct brw_context *brw,
               struct backend_instruction *inst, unsigned offset)
 {
    if (annotation->ann_size <= annotation->ann_count) {
+      int old_size = annotation->ann_size;
       annotation->ann_size = MAX2(1024, annotation->ann_size * 2);
       annotation->ann = reralloc(annotation->mem_ctx, annotation->ann,
                                  struct annotation, annotation->ann_size);
       if (!annotation->ann)
          return;
+
+      memset(annotation->ann + old_size, 0,
+             (annotation->ann_size - old_size) * sizeof(struct annotation));
    }
 
    struct annotation *ann = &annotation->ann[annotation->ann_count++];




More information about the mesa-commit mailing list