mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Don't copy the strtok parameter
This commit is contained in:
parent
84aed3b718
commit
f6ed403fde
3 changed files with 11 additions and 3 deletions
|
@ -849,6 +849,7 @@ PHP_RINIT_FUNCTION(basic)
|
||||||
{
|
{
|
||||||
memset(BG(strtok_table), 0, 256);
|
memset(BG(strtok_table), 0, 256);
|
||||||
BG(strtok_string) = NULL;
|
BG(strtok_string) = NULL;
|
||||||
|
BG(strtok_zval) = NULL;
|
||||||
BG(locale_string) = NULL;
|
BG(locale_string) = NULL;
|
||||||
BG(user_compare_func_name) = NULL;
|
BG(user_compare_func_name) = NULL;
|
||||||
BG(array_walk_func_name) = NULL;
|
BG(array_walk_func_name) = NULL;
|
||||||
|
@ -892,8 +893,10 @@ PHP_RINIT_FUNCTION(basic)
|
||||||
|
|
||||||
PHP_RSHUTDOWN_FUNCTION(basic)
|
PHP_RSHUTDOWN_FUNCTION(basic)
|
||||||
{
|
{
|
||||||
STR_FREE(BG(strtok_string));
|
if (BG(strtok_zval))
|
||||||
|
zval_ptr_dtor(BG(strtok_zval));
|
||||||
BG(strtok_string) = NULL;
|
BG(strtok_string) = NULL;
|
||||||
|
BG(strtok_zval) = NULL;
|
||||||
#ifdef HAVE_PUTENV
|
#ifdef HAVE_PUTENV
|
||||||
zend_hash_destroy(&BG(putenv_ht));
|
zend_hash_destroy(&BG(putenv_ht));
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -141,6 +141,7 @@ typedef signed int php_int32;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
HashTable *user_shutdown_function_names;
|
HashTable *user_shutdown_function_names;
|
||||||
HashTable putenv_ht;
|
HashTable putenv_ht;
|
||||||
|
zval **strtok_zval;
|
||||||
char *strtok_string;
|
char *strtok_string;
|
||||||
char *locale_string;
|
char *locale_string;
|
||||||
char *strtok_last;
|
char *strtok_last;
|
||||||
|
|
|
@ -829,8 +829,12 @@ PHP_FUNCTION(strtok)
|
||||||
tok = args[1];
|
tok = args[1];
|
||||||
convert_to_string_ex(str);
|
convert_to_string_ex(str);
|
||||||
|
|
||||||
STR_FREE(BG(strtok_string));
|
zval_add_ref(str);
|
||||||
BG(strtok_last) = BG(strtok_string) = estrndup(Z_STRVAL_PP(str), Z_STRLEN_PP(str));
|
if (BG(strtok_zval))
|
||||||
|
zval_ptr_dtor(BG(strtok_zval));
|
||||||
|
BG(strtok_zval) = str;
|
||||||
|
|
||||||
|
BG(strtok_last) = BG(strtok_string) = Z_STRVAL_PP(str);
|
||||||
BG(strtok_len) = Z_STRLEN_PP(str);
|
BG(strtok_len) = Z_STRLEN_PP(str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue