summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Braglia <massimiliano.braglia@fazland.com>2018-08-21 17:44:02 +0200
committerNikita Popov <nikita.ppv@gmail.com>2018-08-22 13:39:08 +0200
commit2527a0fcfd949d811f7c015aa676e47a342751b8 (patch)
tree95f91cdf3d41fec0d816daa0a92a4abc66a50cd3
parent7ad05957120ad2c8ee9471aabeceb5d7fa559e5f (diff)
downloadphp-git-2527a0fcfd949d811f7c015aa676e47a342751b8.tar.gz
Fixed bug #75797
Fix zend_register_class_alias_ex() to use non-persistent strings for (non-persistent) userland classes.
-rw-r--r--NEWS2
-rw-r--r--Zend/zend_API.c7
2 files changed, 7 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 9970475dc5..117ad49114 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ PHP NEWS
. Fixed bug #76754 (parent private constant in extends class memory leak).
(Laruence)
. Fixed bug #72443 (Generate enabled extension). (petk)
+ . Fixed bug #75797 (Memory leak when using class_alias() in non-debug mode).
+ (Massimiliano Braglia)
- Bz2:
. Fixed arginfo for bzcompress. (Tyson Andre)
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index fedef6f574..7c4ae7a615 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -2774,12 +2774,15 @@ ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *or
ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce) /* {{{ */
{
zend_string *lcname;
+ int persistent;
+
+ persistent = ce->type != ZEND_USER_CLASS;
if (name[0] == '\\') {
- lcname = zend_string_alloc(name_len-1, 1);
+ lcname = zend_string_alloc(name_len-1, persistent);
zend_str_tolower_copy(ZSTR_VAL(lcname), name+1, name_len-1);
} else {
- lcname = zend_string_alloc(name_len, 1);
+ lcname = zend_string_alloc(name_len, persistent);
zend_str_tolower_copy(ZSTR_VAL(lcname), name, name_len);
}