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@whitecape.org>
This commit is contained in:
Matt Turner 2014-07-08 16:50:28 -07:00
parent 0d711e719e
commit 76caaedd7e
1 changed files with 4 additions and 0 deletions

View 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++];