]> granicus.if.org Git - php/commitdiff
- MFH: Fixed zero bytes memory allocation when no extra ini files are found in
authorDerick Rethans <derick@php.net>
Mon, 16 Feb 2004 14:29:07 +0000 (14:29 +0000)
committerDerick Rethans <derick@php.net>
Mon, 16 Feb 2004 14:29:07 +0000 (14:29 +0000)
  the --with-config-file-scan-dir specified directory. (Eric Colinet, Derick)

main/php_ini.c

index c30818965b6b95b682b7356dd92640e5ea1dab21..02ab9263633de8bff6bbd491dcf46ddd28e80857 100644 (file)
@@ -441,12 +441,14 @@ 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");
-                       }       
+                       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);
                }
        }