From 72c7ae080b05720633070c6a980ee392f431a3c1 Mon Sep 17 00:00:00 2001 From: Jeroen van Wolffelaar Date: Mon, 3 Sep 2001 01:25:24 +0000 Subject: [PATCH] Fix SIGSEGV because HAS_SRAND didn't check wether the entry existed at all --- ext/standard/rand.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/standard/rand.c b/ext/standard/rand.c index cddeca803db..108f58a9ad2 100644 --- a/ext/standard/rand.c +++ b/ext/standard/rand.c @@ -36,7 +36,7 @@ /* an ARRAY of POINTERS, not vice versa */ php_randgen_entry *php_randgen_entries[PHP_RAND_NUMRANDS]; -#define PHP_HAS_SRAND(which) (php_randgen_entries[which]->srand) +#define PHP_HAS_SRAND(which) (php_randgen_entries[which] && php_randgen_entries[which]->srand) #define PHP_SRAND(which,seed) ((*(php_randgen_entries[which]->srand))(seed)) #define PHP_RAND(which) ((*(php_randgen_entries[which]->rand))()) #define PHP_RANDMAX(which) (php_randgen_entries[which]->randmax) @@ -48,6 +48,8 @@ PHP_MINIT_FUNCTION(rand) { PHP_MINIT(rand_sys)(INIT_FUNC_ARGS_PASSTHRU); PHP_MINIT(rand_mt)(INIT_FUNC_ARGS_PASSTHRU); + /* lcg not yet implemented */ + php_randgen_entries[PHP_RAND_LCG] = NULL; } /* TODO: check that this function is called on the start of each script