mirror of
https://github.com/php/php-src.git
synced 2025-01-21 03:03:41 +08:00
fix #36981 (SplFileObject->fgets() ignores max_length)
This commit is contained in:
parent
8f7319a49f
commit
ad7768ee63
1
NEWS
1
NEWS
@ -15,6 +15,7 @@ PHP NEWS
|
||||
- Removed the E_STRICT deprecation notice from "var". (Ilia)
|
||||
- Fixed debug_zval_dump() to support private and protected members. (Dmitry)
|
||||
- Fixed SoapFault::getMessage(). (Dmitry)
|
||||
- Fixed bug #36981 (SplFileObject->fgets() ignores max_length). (Tony)
|
||||
- Fixed bug #36957 (serialize() does not handle recursion). (Ilia)
|
||||
- Fixed bug #36944 (strncmp & strncasecmp do not return false on negative
|
||||
string length). (Tony)
|
||||
|
@ -1327,7 +1327,7 @@ static zend_function_entry spl_RecursiveDirectoryIterator_functions[] = {
|
||||
static int spl_filesystem_file_read(spl_filesystem_object *intern, int silent TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
char *buf;
|
||||
size_t line_len;
|
||||
size_t line_len = 0;
|
||||
int len;
|
||||
long line_add = (intern->u.file.current_line || intern->u.file.current_zval) ? 1 : 0;
|
||||
|
||||
@ -1340,7 +1340,17 @@ static int spl_filesystem_file_read(spl_filesystem_object *intern, int silent TS
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
buf = php_stream_get_line(intern->u.file.stream, NULL, intern->u.file.max_line_len, &line_len);
|
||||
if (intern->u.file.max_line_len > 0) {
|
||||
buf = emalloc((intern->u.file.max_line_len + 1) * sizeof(char));
|
||||
if (php_stream_get_line(intern->u.file.stream, buf, intern->u.file.max_line_len, &line_len) == NULL) {
|
||||
efree(buf);
|
||||
buf = NULL;
|
||||
} else {
|
||||
buf[line_len] = '\0';
|
||||
}
|
||||
} else {
|
||||
buf = php_stream_get_line(intern->u.file.stream, NULL, 0, &line_len);
|
||||
}
|
||||
|
||||
if (!buf) {
|
||||
intern->u.file.current_line = estrdup("");
|
||||
|
Loading…
Reference in New Issue
Block a user