mesa: add missing null checks in _tnl_register_fastpath()
authorJuha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Sun, 27 Apr 2014 20:04:57 +0000 (23:04 +0300)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 2 May 2014 18:58:36 +0000 (11:58 -0700)
Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/tnl/t_vertex.c

index b3deac02491b6081e55f94a31b5793a1c3eaeba5..421bae2b81890382561c1343a8ed974fc67d2a4d 100644 (file)
@@ -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(__func__);
+      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(__func__);
+      return;
+   }
 
    for (i = 0; i < vtx->attr_count; i++) {
       fastpath->attr[i].format = vtx->attr[i].format;