php7_ext_wrapper.h: fix memory leak in php 7

pull/10/head
yuqing 2016-08-01 19:36:32 +08:00
parent 1eab718d4f
commit 60cd0565e5
2 changed files with 17 additions and 8 deletions

View File

@ -1,6 +1,7 @@
Version 1.30 2016-07-25
Version 1.30 2016-08-01
* modify php-fastcommon/test.php
* php7_ext_wrapper.h: fix memory leak in php 7
Version 1.29 2016-06-17
* ini_file_reader support #@if

View File

@ -106,7 +106,7 @@ static inline int zend_get_configuration_directive_wrapper(char *name, int len,
return zend_get_configuration_directive(name, len, *value);
}
#else
#else //php 7
typedef size_t zend_size_t;
#define ZEND_RETURN_STRING(s, dup) RETURN_STRING(s)
@ -187,9 +187,14 @@ static inline int zend_hash_index_find_wrapper(HashTable *ht, int index,
static inline int zend_hash_update_wrapper(HashTable *ht, char *k, int len,
zval **val, int size, void *ptr)
{
zval key;
ZVAL_STRINGL(&key, k, len - 1);
return zend_hash_update(ht, Z_STR(key), *val) ? SUCCESS : FAILURE;
zend_string *key;
bool use_heap;
int result;
ZSTR_ALLOCA_INIT(key, k, len - 1, use_heap);
result = zend_hash_update(ht, key, *val) ? SUCCESS : FAILURE;
ZSTR_ALLOCA_FREE(key, use_heap);
return result;
}
static inline int zend_call_user_function_wrapper(HashTable *function_table,
@ -215,9 +220,12 @@ static inline int zend_call_user_function_wrapper(HashTable *function_table,
static inline int zend_get_configuration_directive_wrapper(char *name, int len,
zval **value)
{
zval key;
ZVAL_STRINGL(&key, name, len - 1);
*value = zend_get_configuration_directive(Z_STR(key));
zend_string *key;
bool use_heap;
ZSTR_ALLOCA_INIT(key, name, len - 1, use_heap);
*value = zend_get_configuration_directive(key);
ZSTR_ALLOCA_FREE(key, use_heap);
return (*value != NULL ? SUCCESS : FAILURE);
}