File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -3875,7 +3875,8 @@ PHPAPI zend_string *php_repr_str(const char *str, size_t len) {
3875
3875
// so we need 4 bytes for each character
3876
3876
// plus 2 byte for the leading quote and the trailing quote
3877
3877
// plus 1 byte for the null terminator
3878
- zend_string * new_str = zend_string_alloc (len * 4 + 2 + 1 , 0 );
3878
+ int alloc_len = len * 4 + 2 + 1 ;
3879
+ zend_string * new_str = zend_string_alloc (alloc_len , 0 );
3879
3880
char * target = ZSTR_VAL (new_str );
3880
3881
// add the leading quote
3881
3882
* target ++ = '"' ;
@@ -3890,7 +3891,7 @@ PHPAPI zend_string *php_repr_str(const char *str, size_t len) {
3890
3891
// add the null terminator
3891
3892
* target = '\0' ;
3892
3893
newlen = target - ZSTR_VAL (new_str );
3893
- if (newlen < len * 4 ) {
3894
+ if (newlen < alloc_len ) {
3894
3895
new_str = zend_string_truncate (new_str , newlen , 0 );
3895
3896
}
3896
3897
return new_str ;
You can’t perform that action at this time.
0 commit comments