Skip to content

Commit

Permalink
Ensure memory is allocated for the null-byte in random_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwakefield committed Jun 23, 2023
1 parent b24c202 commit 4612c8d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fakerandom.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ PHP_FUNCTION(fake_random_bytes)
Z_PARAM_LONG(length)
ZEND_PARSE_PARAMETERS_END();

retval = emalloc(length);
retval = emalloc(length + 1);

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

0 comments on commit 4612c8d

Please sign in to comment.