From e99d4e9adc97398e76f5e8a143207ebcfc81efe5 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 18 May 2009 18:45:30 +0000 Subject: [PATCH] Fixed bug #48313 (fgetcsv() does not return null for empty rows) --- ext/standard/file.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ext/standard/file.c b/ext/standard/file.c index d83f911805..eae751a5cb 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -2343,8 +2343,12 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char } /* 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.40.0