From: Ilia Alshanetsky Date: Mon, 18 May 2009 18:46:06 +0000 (+0000) Subject: MFB: Fixed bug #48313 (fgetcsv() does not return null for empty rows) X-Git-Tag: php-5.2.10RC1~52 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=558d25649d845307715c4f5d6511d3fc8fb4c84b;p=php MFB: Fixed bug #48313 (fgetcsv() does not return null for empty rows) --- diff --git a/NEWS b/NEWS index 4ae3c6c147..bc8d1edf4e 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,7 @@ PHP NEWS - Fixed segfault on invalid session.save_path. (Hannes) - Fixed leaks in imap when a mail_criteria is used. (Pierre) +- Fixed bug #48313 (fgetcsv() does not return null for empty rows). (Ilia) - Fixed bug #48309 (stream_copy_to_stream() and fpasstru() do not update stream position of plain files). (Arnaud) - Fixed bug #48307 (stream_copy_to_stream() copies 0 bytes when $source is a diff --git a/ext/standard/file.c b/ext/standard/file.c index 25887fd8a6..21870c3d32 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -2384,8 +2384,12 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, size } /* 3. Now pass our field back to php */ - *comp_end = '\0'; - add_next_index_stringl(return_value, temp, comp_end - temp, 1); + if (comp_end - temp) { + *comp_end = '\0'; + add_next_index_stringl(return_value, temp, comp_end - temp, 1); + } else { + add_next_index_null(return_value); + } } while (inc_len > 0); out: