From 558d25649d845307715c4f5d6511d3fc8fb4c84b Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 18 May 2009 18:46:06 +0000 Subject: [PATCH] MFB: Fixed bug #48313 (fgetcsv() does not return null for empty rows) --- NEWS | 1 + ext/standard/file.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) 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: -- 2.50.1