Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlo Yatsukhnenko <yatsukhnenko@gmail.com>2019-02-19 22:43:10 +0300
committermichael-grunder <michael.grunder@gmail.com>2019-03-19 23:31:46 +0300
commit95d57a20afde248e7b3376c76c0acbfa110da763 (patch)
tree1a92c05ef833be7090a348e0fb332fdfb51bf9d6 /library.c
parent15d3b9ee222eb95fb5a40c72bf8141724ac07b72 (diff)
Fix memory leak on PHP 5
Diffstat (limited to 'library.c')
-rw-r--r--library.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/library.c b/library.c
index a6aea8af..51dbf2c3 100644
--- a/library.c
+++ b/library.c
@@ -1825,15 +1825,11 @@ redis_sock_disconnect(RedisSock *redis_sock, int force TSRMLS_DC)
zend_string *persistent_id = strpprintf(0, "phpredis_%s:%d", ZSTR_VAL(redis_sock->host), redis_sock->port);
zend_resource *le = zend_hash_find_ptr(&EG(persistent_list), persistent_id);
if (!le) {
-#if (PHP_MAJOR_VERSION < 7)
- le = ecalloc(1, sizeof(*le));
-#else
- zend_resource res;
- le = &res;
-#endif
+ zend_llist *l = pecalloc(1, sizeof(*l) + sizeof(*le), 1);
+ zend_llist_init(l, sizeof(void *), NULL, 1);
+ le = (void *)l + sizeof(*l);
le->type = le_redis_pconnect;
- le->ptr = pecalloc(1, sizeof(zend_llist), 1);
- zend_llist_init(le->ptr, sizeof(void *), NULL, 1);
+ le->ptr = l;
zend_hash_str_update_mem(&EG(persistent_list), ZSTR_VAL(persistent_id), ZSTR_LEN(persistent_id), le, sizeof(*le));
}
zend_llist_prepend_element(le->ptr, &redis_sock->stream);