1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Fix #848, crash at HTTP fast buffer grow 2.0.239

This commit is contained in:
winlin 2017-04-18 11:41:09 +08:00
parent 33a0abdeff
commit 5e284b58a4
3 changed files with 6 additions and 3 deletions

View file

@ -160,9 +160,10 @@ int SrsFastBuffer::grow(ISrsBufferReader* reader, int required_size)
// reset when buffer is empty.
p = end = buffer;
srs_verbose("all consumed, reset fast buffer");
} else {
} else if (nb_exists_bytes < nb_buffer && p > buffer) {
// move the left bytes to start of buffer.
srs_assert(nb_exists_bytes < nb_buffer);
// @remark Only move memory when space is enough, or failed at next check.
// @see https://github.com/ossrs/srs/issues/848
buffer = (char*)memmove(buffer, p, nb_exists_bytes);
p = buffer;
end = p + nb_exists_bytes;