diff options
author | Derick Rethans <derick@php.net> | 2004-02-14 12:29:04 +0000 |
---|---|---|
committer | Derick Rethans <derick@php.net> | 2004-02-14 12:29:04 +0000 |
commit | 3781af53cd6ec7b68a3bb8469556aae6166e0c54 (patch) | |
tree | fd415bb2a055dea87c38d4438a066de46dc25bcb /main | |
parent | ee42c23ce019250a54b7e178111307da1207cc11 (diff) | |
download | php-git-3781af53cd6ec7b68a3bb8469556aae6166e0c54.tar.gz |
- Fixed zero bytes memory allocation when no extra ini files are found in the
--with-config-file-scan-dir specified directory. (patch by Eric Colinet
<e.colinet@laposte.net>)
Diffstat (limited to 'main')
-rw-r--r-- | main/php_ini.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/main/php_ini.c b/main/php_ini.c index 8fd1c00f9a..d1c2872931 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -512,13 +512,15 @@ int php_init_config() * Don't need an extra byte for the \0 in this malloc as the last * element will not get a trailing , which gives us the byte for the \0 */ - php_ini_scanned_files = (char *) malloc(total_l); - *php_ini_scanned_files = '\0'; - for (element = scanned_ini_list.head; element; element = element->next) { - strcat(php_ini_scanned_files, *(char **)element->data); - strcat(php_ini_scanned_files, element->next ? ",\n" : "\n"); - } - zend_llist_destroy(&scanned_ini_list); + if (total_l) { + php_ini_scanned_files = (char *) malloc(total_l); + *php_ini_scanned_files = '\0'; + for (element = scanned_ini_list.head; element; element = element->next) { + strcat(php_ini_scanned_files, *(char **)element->data); + strcat(php_ini_scanned_files, element->next ? ",\n" : "\n"); + } + zend_llist_destroy(&scanned_ini_list); + } } } return SUCCESS; |