i965: Initialize new chunks of realloc'd memory.
authorMatt Turner <mattst88@gmail.com>
Tue, 8 Jul 2014 23:50:28 +0000 (16:50 -0700)
committerMatt Turner <mattst88@gmail.com>
Tue, 15 Jul 2014 17:12:29 +0000 (10:12 -0700)
Otherwise we'd compare uninitialized pointers with NULL and dereference,
leading to crashes.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/intel_asm_annotation.c

index 4717baf..6a51d89 100644 (file)
@@ -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++];