[Mesa-dev] [PATCH 04/20] mesa: add missing null check in _mesa_NewHashTable()

Ian Romanick idr at freedesktop.org
Wed May 14 12:55:15 PDT 2014


Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

On 05/14/2014 10:55 AM, Juha-Pekka Heikkila wrote:
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> ---
>  src/mesa/main/hash.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c
> index 23018e9..674c29d 100644
> --- a/src/mesa/main/hash.c
> +++ b/src/mesa/main/hash.c
> @@ -115,10 +115,20 @@ _mesa_NewHashTable(void)
>  
>     if (table) {
>        table->ht = _mesa_hash_table_create(NULL, uint_key_compare);
> +      if (table->ht == NULL) {
> +         free(table);
> +         _mesa_error_no_memory(__func__);
> +         return NULL;
> +      }
> +
>        _mesa_hash_table_set_deleted_key(table->ht, uint_key(DELETED_KEY_VALUE));
>        mtx_init(&table->Mutex, mtx_plain);
>        mtx_init(&table->WalkMutex, mtx_plain);
>     }
> +   else {
> +      _mesa_error_no_memory(__func__);
> +   }
> +
>     return table;
>  }
>  
> 



More information about the mesa-dev mailing list