Skip to content

Commit

Permalink
Fix persistent smart_str allocation
Browse files Browse the repository at this point in the history
This would allocate a too small buffer if the first smart_str
allocation is > SMART_STR_START_LEN but <= SMART_STR_START_SIZE.

(cherry picked from commit af8fcce)
  • Loading branch information
nikic authored and cmb69 committed Sep 21, 2021
1 parent df2ceac commit 549cb44
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Zend/zend_smart_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ZEND_API void ZEND_FASTCALL smart_str_erealloc(smart_str *str, size_t len)
ZEND_API void ZEND_FASTCALL smart_str_realloc(smart_str *str, size_t len)
{
if (UNEXPECTED(!str->s)) {
str->a = len <= SMART_STR_START_SIZE
str->a = len <= SMART_STR_START_LEN
? SMART_STR_START_LEN
: SMART_STR_NEW_LEN(len);
str->s = zend_string_alloc(str->a, 1);
Expand Down

0 comments on commit 549cb44

Please sign in to comment.