[Mesa-dev] [PATCH] i965: Initialize new chunks of realloc'd memory.

Kenneth Graunke kenneth at whitecape.org
Mon Jul 14 14:40:56 PDT 2014


On Wednesday, July 09, 2014 12:41:25 PM Matt Turner wrote:
> Otherwise we'd compare uninitialized pointers with NULL and dereference,
> leading to crashes.
> ---
>  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++];
> 

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140714/d5ab7a6e/attachment.sig>


More information about the mesa-dev mailing list