From: Dmitry Stogov Date: Wed, 16 Apr 2014 16:59:02 +0000 (+0400) Subject: Prevented modification of interned string X-Git-Tag: POST_PHPNG_MERGE~412^2~82^2~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a9aa5224e7a02a1a15097e5d310a1bc79f1fa560;p=php Prevented modification of interned string --- diff --git a/ext/standard/string.c b/ext/standard/string.c index 290fa21879..764f82150c 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -4283,12 +4283,23 @@ PHP_FUNCTION(strip_tags) /* To maintain a certain BC, we allow anything for the second parameter and return original string */ if (allow != NULL) { convert_to_string_ex(allow); - allowed_tags = Z_STRVAL_P(allow); - allowed_tags_len = Z_STRLEN_P(allow); +// TODO: reimplement to avoid reallocation ??? + if (IS_INTERNED(Z_STR_P(allow))) { + allowed_tags = estrndup(Z_STRVAL_P(allow), Z_STRLEN_P(allow)); + allowed_tags_len = Z_STRLEN_P(allow); + } else { + allowed_tags = Z_STRVAL_P(allow); + allowed_tags_len = Z_STRLEN_P(allow); + } } buf = STR_INIT(str, str_len, 0); buf->len = php_strip_tags_ex(buf->val, str_len, NULL, allowed_tags, allowed_tags_len, 0); + +// TODO: reimplement to avoid reallocation ??? + if (allow && IS_INTERNED(Z_STR_P(allow))) { + efree(allowed_tags); + } RETURN_STR(buf); } /* }}} */