diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-08-27 12:24:58 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-08-27 12:24:58 +0200 |
commit | ce83ec87909331e9a643e4e81c33524c0994641f (patch) | |
tree | 489bba609ede7cb5af5105a574d7b3dd54f87565 /ext/standard/basic_functions.c | |
parent | 0026d8a7838914296c0d7e99ddc639c84e6ebb8a (diff) | |
download | php-git-ce83ec87909331e9a643e4e81c33524c0994641f.tar.gz |
Clean up strtok implementation
Store the zend_string instead of performing a copy and storing
in a zval. Also make sure the string is released immediately if
it's no longer needed. Finally, avoid null pointer offset UB if
no string has been set -- though I'm wondering if this case
shouldn't be generating a warning?
Diffstat (limited to 'ext/standard/basic_functions.c')
-rwxr-xr-x | ext/standard/basic_functions.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 51a44a3ffb..b2b30a05e4 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -458,7 +458,6 @@ PHP_RINIT_FUNCTION(basic) /* {{{ */ memset(&BG(unserialize), 0, sizeof(BG(unserialize))); BG(strtok_string) = NULL; - ZVAL_UNDEF(&BG(strtok_zval)); BG(strtok_last) = NULL; BG(ctype_string) = NULL; BG(locale_changed) = 0; @@ -497,9 +496,10 @@ PHP_RINIT_FUNCTION(basic) /* {{{ */ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */ { - zval_ptr_dtor(&BG(strtok_zval)); - ZVAL_UNDEF(&BG(strtok_zval)); - BG(strtok_string) = NULL; + if (BG(strtok_string)) { + zend_string_release(BG(strtok_string)); + BG(strtok_string) = NULL; + } #ifdef HAVE_PUTENV tsrm_env_lock(); zend_hash_destroy(&BG(putenv_ht)); |