commit a78c2029928ad56ff7972aee26fe25f6f41ee981
parent 6548e67fcbe947a8b9aef797bcccb7429e4243ff
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 14 Mar 2017 08:17:23 +0100
Fix the ssol_mc_shape_get_mc_primitive_function
Return an error if the submitted primitive index exceeds the number of
primitives of the associated shape.
Diffstat:
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/ssol.h b/src/ssol.h
@@ -320,6 +320,7 @@ struct ssol_mc_shape {
/* Internal data */
size_t N__;
void* mc__;
+ const struct ssol_shape* shape__;
};
struct ssol_mc_primitive {
diff --git a/src/ssol_mc_receiver.c b/src/ssol_mc_receiver.c
@@ -71,6 +71,7 @@ ssol_mc_receiver_get_mc_shape
mc_rcv1 = rcv->mc__;
mc->N__ = rcv->N__;
mc->mc__ = htable_shape2mc_find(&mc_rcv1->shape2mc, &shape);
+ mc->shape__ = shape;
return RES_OK;
}
@@ -82,9 +83,13 @@ ssol_mc_shape_get_mc_primitive
{
struct mc_shape_1side* mc_shape1;
struct mc_primitive_1side* mc_prim1;
+ unsigned ntris;
if(!shape || !prim) return RES_BAD_ARG;
+ SSOL(shape_get_triangles_count(shape->shape__, &ntris));
+ if(i >= ntris) return RES_BAD_ARG;
+
mc_shape1 = shape->mc__;
if(!mc_shape1 || !(mc_prim1 = htable_prim2mc_find(&mc_shape1->prim2mc, &i))) {
#define SETUP_MC_RESULT(Name) { \