mirror of
https://github.com/php/php-src.git
synced 2025-08-21 01:45:16 +02:00
- Fix issue in _php_stream_get_line(): Allow maxchars == 0 as macro
php_stream_get_line() does
This commit is contained in:
parent
7fc0756e55
commit
d7a4909ed2
1 changed files with 17 additions and 13 deletions
|
@ -1053,6 +1053,7 @@ PHPAPI void *_php_stream_get_line(php_stream *stream, int buf_type, zstr buf, si
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_unicode) {
|
if (is_unicode) {
|
||||||
|
if (maxchars) {
|
||||||
int ulen = u_countChar32(readptr.u, cpysz);
|
int ulen = u_countChar32(readptr.u, cpysz);
|
||||||
|
|
||||||
if (ulen > maxchars) {
|
if (ulen > maxchars) {
|
||||||
|
@ -1063,10 +1064,11 @@ PHPAPI void *_php_stream_get_line(php_stream *stream, int buf_type, zstr buf, si
|
||||||
cpysz = i;
|
cpysz = i;
|
||||||
}
|
}
|
||||||
maxchars -= ulen;
|
maxchars -= ulen;
|
||||||
|
}
|
||||||
memcpy(buf.u, readptr.u, UBYTES(cpysz));
|
memcpy(buf.u, readptr.u, UBYTES(cpysz));
|
||||||
buf.u += cpysz;
|
buf.u += cpysz;
|
||||||
} else {
|
} else {
|
||||||
if (cpysz > maxchars) {
|
if (maxchars && cpysz > maxchars) {
|
||||||
cpysz = maxchars;
|
cpysz = maxchars;
|
||||||
}
|
}
|
||||||
memcpy(buf.s, readptr.s, cpysz);
|
memcpy(buf.s, readptr.s, cpysz);
|
||||||
|
@ -1105,10 +1107,12 @@ PHPAPI void *_php_stream_get_line(php_stream *stream, int buf_type, zstr buf, si
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (total_copied == 0) {
|
if (returned_len) {
|
||||||
if (grow_mode) {
|
*returned_len = total_copied;
|
||||||
assert(bufstart.v == NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (total_copied == 0) {
|
||||||
|
assert(bufstart.v != NULL || !grow_mode || stream->eof);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue