star-sp

Random number generators and distributions
git clone git://git.meso-star.fr/star-sp.git
Log | Files | Refs | README | LICENSE

commit 01b798d1f0882bb6a25e582af66532dd38b22fa0
parent 5ab054a9d535b80a47b6b5707918af33f58204db
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed,  2 Dec 2020 10:30:38 +0100

Fix the ssp_rng_proxy_create2 function

Return an error if the submitted initial RNG state is a bucket RNG, i.e.
a RNG that is managed by a proxy.

Diffstat:
Msrc/ssp_rng_proxy.c | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/ssp_rng_proxy.c b/src/ssp_rng_proxy.c @@ -623,6 +623,13 @@ ssp_rng_proxy_create2 * submitted RNG type if any */ res = ssp_rng_get_type(args->rng, &proxy->type); if(res != RES_OK) goto error; + + /* Bucket RNG is not allowed to be a proxy RNG */ + if(proxy->type.init == rng_bucket_init) { + res = RES_BAD_ARG; + goto error; + } + res = ssp_rng_create(allocator, &proxy->type, &proxy->rng); if(res != RES_OK) goto error;