diff --git a/ext/standard/file.c b/ext/standard/file.c index d83f9118050..eae751a5cbb 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: