[Mesa-dev] [PATCH 02/11] mesa: add missing null checks in _tnl_register_fastpath()

Ian Romanick idr at freedesktop.org
Fri Apr 4 13:21:19 PDT 2014


On 04/04/2014 03:27 AM, Juha-Pekka Heikkila wrote:
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> Reviewed-by: Matt Turner <mattst88 at gmail.com>
> ---
>  src/mesa/tnl/t_vertex.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c
> index b3deac0..5cdf743 100644
> --- a/src/mesa/tnl/t_vertex.c
> +++ b/src/mesa/tnl/t_vertex.c
> @@ -83,12 +83,22 @@ void _tnl_register_fastpath( struct tnl_clipspace *vtx,
>     struct tnl_clipspace_fastpath *fastpath = CALLOC_STRUCT(tnl_clipspace_fastpath);
>     GLuint i;
>  
> +   if (fastpath == NULL) {
> +      _mesa_error_no_memory(__FUNCTION__);

I believe people are trying to remove instances of __FUNCTION__ as it is
non-standard.  I'd swear that I had recently seen patches that
s/__FUNCTION__/__func__/g on the list, but I can't find them now.

http://stackoverflow.com/questions/7008485/func-or-function-or-manual-const-char-id/

> +      return;
> +   }
> +
>     fastpath->vertex_size = vtx->vertex_size;
>     fastpath->attr_count = vtx->attr_count;
>     fastpath->match_strides = match_strides;
>     fastpath->func = vtx->emit;
> -   fastpath->attr =
> -      malloc(vtx->attr_count * sizeof(fastpath->attr[0]));
> +   fastpath->attr = malloc(vtx->attr_count * sizeof(fastpath->attr[0]));
> +
> +   if (fastpath->attr == NULL) {
> +      FREE(fastpath);
> +      _mesa_error_no_memory(__FUNCTION__);
> +      return;
> +   }
>  
>     for (i = 0; i < vtx->attr_count; i++) {
>        fastpath->attr[i].format = vtx->attr[i].format;
> 



More information about the mesa-dev mailing list