[Mesa-dev] [PATCH 02/20] mesa: Add missing null checks into prog_hash_table.c

Tapani Pälli tapani.palli at intel.com
Thu May 29 21:48:00 PDT 2014


This breaks 'make check', I've send a patch that fixes it for me.

On 05/14/2014 08:55 PM, Juha-Pekka Heikkila wrote:
> Check calloc return values in hash_table_insert() and
> hash_table_replace()
>
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> ---
>  src/mesa/program/prog_hash_table.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/src/mesa/program/prog_hash_table.c b/src/mesa/program/prog_hash_table.c
> index f45ed46..2445d84 100644
> --- a/src/mesa/program/prog_hash_table.c
> +++ b/src/mesa/program/prog_hash_table.c
> @@ -142,6 +142,10 @@ hash_table_insert(struct hash_table *ht, void *data, const void *key)
>      struct hash_node *node;
>  
>      node = calloc(1, sizeof(*node));
> +    if (node == NULL) {
> +       _mesa_error_no_memory(__func__);
> +       return;
> +    }
>  
>      node->data = data;
>      node->key = key;
> @@ -167,6 +171,10 @@ hash_table_replace(struct hash_table *ht, void *data, const void *key)
>      }
>  
>      hn = calloc(1, sizeof(*hn));
> +    if (hn == NULL) {
> +       _mesa_error_no_memory(__func__);
> +       return false;
> +    }
>  
>      hn->data = data;
>      hn->key = key;



More information about the mesa-dev mailing list