Skip to content

Commit 4612c8d

Browse files
committed
Ensure memory is allocated for the null-byte in random_bytes
1 parent b24c202 commit 4612c8d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fakerandom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ PHP_FUNCTION(fake_random_bytes)
4343
Z_PARAM_LONG(length)
4444
ZEND_PARSE_PARAMETERS_END();
4545

46-
retval = emalloc(length);
46+
retval = emalloc(length + 1);
4747

4848
for (size_t i = 0; i < length; i++) {
4949
retval[i] = (char)((i + 1) % 256);

0 commit comments

Comments
 (0)