From 1b97f290cf35c3462ed6bf6939f6286bc8b12d7a Mon Sep 17 00:00:00 2001 From: hasufell Date: Sat, 10 May 2014 22:48:50 +0200 Subject: [PATCH] Improve error handling in find_center() --- src/half_edge.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/half_edge.c b/src/half_edge.c index b2d8c8c..d85743a 100644 --- a/src/half_edge.c +++ b/src/half_edge.c @@ -59,7 +59,12 @@ HE_vert *find_center(HE_obj const * const obj) y = 0, z = 0; uint32_t i; - HE_vert *newvert = malloc(sizeof(HE_vert)); + HE_vert *newvert; + + if (!obj) + return NULL; + + newvert = malloc(sizeof(HE_vert)); for (i = 0; i < obj->vc; i++) { x += obj->vertices[i].x;