php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #71482
Patch php_pcre_segfault revision 2016-01-29 09:13 UTC by alex dot schneider at sevenval dot com

Patch php_pcre_segfault for PCRE related Bug #71482

Patch version 2016-01-29 09:13 UTC

Return to Bug #71482 | Download this patch
Patch Revisions:

Developer: alex.schneider@sevenval.com

diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 6769eb7..3b52d1f 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -508,22 +508,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
 		return NULL;
 	}
 
-	/*
-	 * Interned strings are not duplicated when stored in HashTable,
-	 * but all the interned strings created during HTTP request are removed
-	 * at end of request. However PCRE_G(pcre_cache) must be consistent
-	 * on the next request as well. So we disable usage of interned strings
-	 * as hash keys especually for this table.
-	 * See bug #63180
-	 */
-	if (!ZSTR_IS_INTERNED(regex) || !(GC_FLAGS(regex) & IS_STR_PERMANENT)) {
-		zend_string *str = zend_string_init(ZSTR_VAL(regex), ZSTR_LEN(regex), 1);
-		GC_REFCOUNT(str) = 0; /* will be incremented by zend_hash_update_mem() */
-		ZSTR_H(str) = ZSTR_H(regex);
-		regex = str;
-	}
-
-	pce = zend_hash_update_mem(&PCRE_G(pcre_cache), regex, &new_entry, sizeof(pcre_cache_entry));
+	pce = zend_hash_str_update_mem(&PCRE_G(pcre_cache), ZSTR_VAL(regex), ZSTR_LEN(regex), &new_entry, sizeof(pcre_cache_entry));
 
 	return pce;
 }
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 01:01:30 2024 UTC