commit 411db4829bbecfbdd9504cd8c7caeb844fcc6855
parent 4b134a9d7ebbe1b314e541339b4b2daf85010e28
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Sat, 13 Jun 2015 07:57:44 +0200
BugFix: fix a crash if a RNG cannot init properly
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/ssp_rng.c b/src/ssp_rng.c
@@ -390,7 +390,9 @@ rng_release(ref_T* ref)
ASSERT(ref);
rng = CONTAINER_OF(ref, struct ssp_rng, ref);
if(rng->state) {
- rng->type.release(rng->state);
+ if (rng->type.release) {
+ rng->type.release(rng->state);
+ }
MEM_RM(rng->allocator, rng->state);
}
MEM_RM(rng->allocator, rng);
@@ -428,7 +430,11 @@ ssp_rng_create
res = RES_MEM_ERR;
goto error;
}
- type->init(allocator, rng->state);
+ res = type->init(allocator, rng->state);
+ if (res != RES_OK)
+ {
+ goto error;
+ }
rng->type = *type;
exit: