diff options
| author | Sander Roobol <sander@php.net> | 2002-10-06 11:28:11 +0000 |
|---|---|---|
| committer | Sander Roobol <sander@php.net> | 2002-10-06 11:28:11 +0000 |
| commit | 68cd0676700f884a8b1d5144212ab7520c2078c6 (patch) | |
| tree | c2de98a709585a010ca465c01576ba4d12230631 | |
| parent | 8cf14a42f5097726411dbeeaa71ceed2797311a1 (diff) | |
| download | php-git-68cd0676700f884a8b1d5144212ab7520c2078c6.tar.gz | |
Fixed segfault and memory leak in the new implementation of implode()
| -rw-r--r-- | ext/standard/string.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c index a29c9b52a6..eed9184d7b 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -825,6 +825,10 @@ PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value) numelems = zend_hash_num_elements(Z_ARRVAL_P(arr)); + if(numelems == 0) { + RETURN_EMPTY_STRING(); + } + zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(arr), &pos); while (zend_hash_get_current_data_ex(Z_ARRVAL_P(arr), (void **) &tmp, @@ -888,6 +892,8 @@ PHP_FUNCTION(implode) zval_ptr_dtor(arg1); if (arg2) { zval_ptr_dtor(arg2); + } else { + FREE_ZVAL(delim); } } /* }}} */ |
