From 7a5f83524466075a8796fdd71bb422f49e31d122 Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Fri, 30 Jan 2015 11:19:17 +0100 Subject: [PATCH] cpml: correct put_intersections() bug Call recursively because it is too late for swapping the arguments: the class data has been already initialized. Also, check if put_intersections is implemented only after the recursion. --- src/cpml/cpml-primitive.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cpml/cpml-primitive.c b/src/cpml/cpml-primitive.c index 7f19ef02..c259c843 100644 --- a/src/cpml/cpml-primitive.c +++ b/src/cpml/cpml-primitive.c @@ -498,22 +498,26 @@ cpml_primitive_put_intersections(const CpmlPrimitive *primitive, return 0; class_data = _cpml_class_from_obj(primitive); - if (class_data == NULL || class_data->put_intersections == NULL) + if (class_data == NULL) return 0; n_points = cpml_primitive_get_n_points(primitive); n_points2 = cpml_primitive_get_n_points(primitive2); + /* Check if the primitives can intersect */ if (n_points == 0 || n_points2 == 0) return 0; /* Primitives reordering: the first must be the more complex one */ if (n_points < n_points2) { - const CpmlPrimitive *old_primitive2 = primitive2; - primitive2 = primitive; - primitive = old_primitive2; + return cpml_primitive_put_intersections(primitive2, primitive, + n_dest, dest); } + /* Check if put_intersections is implemented */ + if (class_data->put_intersections == NULL) + return 0; + return class_data->put_intersections(primitive, primitive2, n_dest, dest); } -- 2.11.4.GIT