Skip to content

Commit 2ae9626

Browse files
committed
fix uninitialized memory access (emalloc -> ecalloc)
1 parent cb8d050 commit 2ae9626

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ext/random/random.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static inline zend_object *php_random_engine_common_init(zend_class_entry *ce, c
283283

284284
engine->algo = algo;
285285
if (engine->algo->state_size > 0) {
286-
engine->state = emalloc(engine->algo->state_size);
286+
engine->state = ecalloc(1, engine->algo->state_size);
287287
}
288288
engine->std.handlers = handlers;
289289

@@ -839,6 +839,7 @@ static void php_random_randomizer_common_init(php_random_randomizer *randomizer,
839839

840840
/* Create compatible state */
841841
state->object = engine_object;
842+
state->last_generate_size = 0;
842843
state->generate_method = generate_method;
843844

844845
/* Copy common pointers */

0 commit comments

Comments
 (0)