winlin

Fix #848, crash at HTTP fast buffer grow 2.0.239

@@ -336,6 +336,7 @@ Remark: @@ -336,6 +336,7 @@ Remark:
336 336
337 ## History 337 ## History
338 338
  339 +* v2.0, 2017-04-18, Fix [#848][bug #848], crash at HTTP fast buffer grow 2.0.239
339 * v2.0, 2017-04-15, Fix [#844][bug #844], support Haivision encoder. 2.0.238 340 * v2.0, 2017-04-15, Fix [#844][bug #844], support Haivision encoder. 2.0.238
340 * v2.0, 2017-04-15, Merge [#846][bug #846], fix fd leak for FLV stream caster. 2.0.237 341 * v2.0, 2017-04-15, Merge [#846][bug #846], fix fd leak for FLV stream caster. 2.0.237
341 * v2.0, 2017-04-15, Merge [#841][bug #841], avoid the duplicated sps/pps in ts. 2.0.236 342 * v2.0, 2017-04-15, Merge [#841][bug #841], avoid the duplicated sps/pps in ts. 2.0.236
@@ -1287,6 +1288,7 @@ Winlin @@ -1287,6 +1288,7 @@ Winlin
1287 [bug #841]: https://github.com/ossrs/srs/issues/841 1288 [bug #841]: https://github.com/ossrs/srs/issues/841
1288 [bug #846]: https://github.com/ossrs/srs/issues/846 1289 [bug #846]: https://github.com/ossrs/srs/issues/846
1289 [bug #844]: https://github.com/ossrs/srs/issues/844 1290 [bug #844]: https://github.com/ossrs/srs/issues/844
  1291 +[bug #848]: https://github.com/ossrs/srs/issues/848
1290 [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx 1292 [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx
1291 1293
1292 [exo #828]: https://github.com/google/ExoPlayer/pull/828 1294 [exo #828]: https://github.com/google/ExoPlayer/pull/828
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR 2 32 #define VERSION_MAJOR 2
33 #define VERSION_MINOR 0 33 #define VERSION_MINOR 0
34 -#define VERSION_REVISION 238 34 +#define VERSION_REVISION 239
35 35
36 // generated by configure, only macros. 36 // generated by configure, only macros.
37 #include <srs_auto_headers.hpp> 37 #include <srs_auto_headers.hpp>
@@ -160,9 +160,10 @@ int SrsFastBuffer::grow(ISrsBufferReader* reader, int required_size) @@ -160,9 +160,10 @@ int SrsFastBuffer::grow(ISrsBufferReader* reader, int required_size)
160 // reset when buffer is empty. 160 // reset when buffer is empty.
161 p = end = buffer; 161 p = end = buffer;
162 srs_verbose("all consumed, reset fast buffer"); 162 srs_verbose("all consumed, reset fast buffer");
163 - } else { 163 + } else if (nb_exists_bytes < nb_buffer && p > buffer) {
164 // move the left bytes to start of buffer. 164 // move the left bytes to start of buffer.
165 - srs_assert(nb_exists_bytes < nb_buffer); 165 + // @remark Only move memory when space is enough, or failed at next check.
  166 + // @see https://github.com/ossrs/srs/issues/848
166 buffer = (char*)memmove(buffer, p, nb_exists_bytes); 167 buffer = (char*)memmove(buffer, p, nb_exists_bytes);
167 p = buffer; 168 p = buffer;
168 end = p + nb_exists_bytes; 169 end = p + nb_exists_bytes;