From 1ea718c28385fbcb2c619f3bbfd301fe7d83e4b2 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Mon, 8 Jul 2013 08:38:54 +0100 Subject: [PATCH] Fix memleak reported by Coverity. NB: Fixes Coverity CID1039654 Signed-off-by: Chris Michael --- src/modules/evas/engines/gl_common/evas_gl_polygon.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modules/evas/engines/gl_common/evas_gl_polygon.c b/src/modules/evas/engines/gl_common/evas_gl_polygon.c index 536d2fcf95..f143d4cf30 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_polygon.c +++ b/src/modules/evas/engines/gl_common/evas_gl_polygon.c @@ -70,10 +70,16 @@ evas_gl_common_poly_point_add(Evas_GL_Polygon *poly, int x, int y) { Evas_GL_Polygon_Point *pt; - if (!poly) poly = calloc(1, sizeof(Evas_GL_Polygon)); - if (!poly) return NULL; pt = calloc(1, sizeof(Evas_GL_Polygon_Point)); if (!pt) return NULL; + + if (!poly) poly = calloc(1, sizeof(Evas_GL_Polygon)); + if (!poly) + { + free(pt); + return NULL; + } + pt->x = x; pt->y = y; poly->points = eina_list_append(poly->points, pt);