]> granicus.if.org Git - php/commitdiff
Don't copy the strtok parameter
authorSascha Schumann <sas@php.net>
Fri, 3 Aug 2001 09:50:38 +0000 (09:50 +0000)
committerSascha Schumann <sas@php.net>
Fri, 3 Aug 2001 09:50:38 +0000 (09:50 +0000)
ext/standard/basic_functions.c
ext/standard/basic_functions.h
ext/standard/string.c

index 8cea4eeac0c688fa80f2ed923ab22711ddc46787..e136a4298c5e89f7df9acaff1eb69795d48de637 100644 (file)
@@ -849,6 +849,7 @@ PHP_RINIT_FUNCTION(basic)
 {
        memset(BG(strtok_table), 0, 256);
        BG(strtok_string) = NULL;
+       BG(strtok_zval) = NULL;
        BG(locale_string) = NULL;
        BG(user_compare_func_name) = NULL;
        BG(array_walk_func_name) = NULL;
@@ -892,8 +893,10 @@ PHP_RINIT_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_zval) = NULL;
 #ifdef HAVE_PUTENV
        zend_hash_destroy(&BG(putenv_ht));
 #endif
index 30b71de6575275e9c5ba050a0b9bd31a20fed628..900a1b13f5b9757a9c7dabdc7c2781d6ea16d8f7 100644 (file)
@@ -141,6 +141,7 @@ typedef signed int php_int32;
 typedef struct {
        HashTable *user_shutdown_function_names;
        HashTable putenv_ht;
+       zval **strtok_zval;
        char *strtok_string;
        char *locale_string;
        char *strtok_last;
index c62d78a12024955894785e68865fa5ba87313dfa..ad1a246db39ab46bd518eb920a766e921ad7fb78 100644 (file)
@@ -829,8 +829,12 @@ PHP_FUNCTION(strtok)
                tok = args[1];
                convert_to_string_ex(str);
 
-               STR_FREE(BG(strtok_string));
-               BG(strtok_last) = BG(strtok_string) = estrndup(Z_STRVAL_PP(str), Z_STRLEN_PP(str));
+               zval_add_ref(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);
                break;
        }