commit 532c4d3c6424ec3fcf824d6795f79302609bf97b
parent 29b923da57a9277fa84c14b98925a90abbb1f914
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Tue, 23 Aug 2016 13:31:42 +0200
Fix arg checking for sun/scene attach/detach functions
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/ssol_scene.c b/src/ssol_scene.c
@@ -207,7 +207,9 @@ ssol_scene_clear(struct ssol_scene* scene)
res_T
ssol_scene_attach_sun(struct ssol_scene* scene, struct ssol_sun* sun)
{
- if (!scene || ! sun || sun->scene_attachment)
+ if (!scene || ! sun
+ || sun->scene_attachment /* should detach this sun first from its own scene */
+ || scene->sun) /* should detach previous sun first */
return RES_BAD_ARG;
SSOL(sun_ref_get(sun));
@@ -219,7 +221,7 @@ ssol_scene_attach_sun(struct ssol_scene* scene, struct ssol_sun* sun)
res_T
ssol_scene_detach_sun(struct ssol_scene* scene, struct ssol_sun* sun)
{
- if (!scene || !sun || sun->scene_attachment != scene)
+ if (!scene || !sun || !scene->sun || sun->scene_attachment != scene)
return RES_BAD_ARG;
ASSERT(sun == scene->sun);