Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7472 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 731 invoked by uid 1010); 2 Feb 2004 09:38:30 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 685 invoked from network); 2 Feb 2004 09:38:30 -0000 Received: from unknown (HELO mwinf0401.wanadoo.fr) (193.252.22.27) by pb1.pair.com with SMTP; 2 Feb 2004 09:38:30 -0000 Received: from legolas.laposte.net (AMontsouris-108-1-8-195.w217-128.abo.wanadoo.fr [217.128.29.195]) by mwinf0401.wanadoo.fr (SMTP Server) with ESMTP id 0A30058001D0 for ; Mon, 2 Feb 2004 10:38:29 +0100 (CET) Message-ID: <6.0.1.1.0.20040202103452.01ae7900@pop.laposte.net> X-Sender: e.colinet@pop.laposte.net (Unverified) X-Mailer: QUALCOMM Windows Eudora Version 6.0.1.1 Date: Mon, 02 Feb 2004 10:36:28 +0100 To: internals@lists.php.net Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=====================_6698862==_" Subject: php_init_config zero length allocation From: e.colinet@laposte.net (Eric Colinet) --=====================_6698862==_ Content-Type: text/plain; charset="us-ascii"; format=flowed Hi, Included a patch that avoid a zero length allocation in php_init_config when: - A configuration line like --with-config-file-scan-dir=d:/local/etc is given - The directory specified doesn't contain any *.ini files Let me know if I have to create a bug entry for it before posting a fix. Eric --=====================_6698862==_ Content-Type: text/plain; charset="us-ascii" Content-Disposition: attachment; filename="php_ini_c_z_len_alloc_fix.txt" Index: php_ini.c =================================================================== RCS file: /repository/php-src/main/php_ini.c,v retrieving revision 1.125 diff -u -3 -r1.125 php_ini.c --- php_ini.c 8 Jan 2004 08:17:53 -0000 1.125 +++ php_ini.c 2 Feb 2004 09:21:19 -0000 @@ -512,13 +512,15 @@ * 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; --=====================_6698862==_--