Fix memory overwriting issue caused by buffer rework

This fixes an issue caused by commit fe46a8e “Refactor the basic buffer” in 1.7.3, and seen when streaming HDS to a player. I also added a test case :)