Add initialization paranoia

This commit is contained in:
Landon Curt Noll
2021-11-30 03:35:09 -08:00
parent c4e5007587
commit 51b933dfff

View File

@@ -2663,6 +2663,9 @@ zrandomskip(long cnt)
free(p_blum); free(p_blum);
} }
loglogn = (long)blum.loglogn; loglogn = (long)blum.loglogn;
new_r.len = 0; /* paranoia */
new_r.v = NULL;
new_r.sign = 0;
/* /*
* skip required bits in the buffer * skip required bits in the buffer
@@ -2769,6 +2772,9 @@ zrandom(long cnt, ZVALUE *res)
} }
loglogn = blum.loglogn; loglogn = blum.loglogn;
mask = blum.mask; mask = blum.mask;
new_r.len = 0; /* paranoia */
new_r.v = NULL;
new_r.sign = 0;
/* /*
* allocate storage * allocate storage
@@ -3062,23 +3068,16 @@ randomcopy(CONST RANDOM *state)
void void
randomfree(RANDOM *state) randomfree(RANDOM *state)
{ {
#if 0
/* avoid free of the pre-defined states */
if (state == &init_blum) {
return;
}
if (state >= &random_pregen[0] &&
state <= &random_pregen[BLUM_PREGEN-1]) {
return;
}
#endif
/* free the values */ /* free the values */
zfree_random(state->n); zfree_random(state->n);
zfree_random(state->r); zfree_random(state->r);
/* free it if it is not pre-defined */ /* free it if it is not pre-defined */
state->seeded = 0; state->seeded = 0;
state->bits = 0; /* paranoia */
state->buffer = 0;
/* free it if it is not pre-defined */
if (state != &blum) { if (state != &blum) {
free(state); free(state);
} }