Mesa (master): mesa: add missing null checks in _tnl_register_fastpath()

Ian Romanick idr at kemper.freedesktop.org
Fri May 2 19:03:31 UTC 2014


Module: Mesa
Branch: master
Commit: dc675919d30df407269a5e5b3d682e7801db3f1e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=dc675919d30df407269a5e5b3d682e7801db3f1e

Author: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
Date:   Sun Apr 27 23:04:57 2014 +0300

mesa: add missing null checks in _tnl_register_fastpath()

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.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..421bae2 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(__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;




More information about the mesa-commit mailing list