Branch: Tag:


2017-11-01 15:43:47 by Arne Goedeke <>

Stdio.Buffer()->trim(): fixed possible memcpy on overlapping regions

trim() will move data inside of the buffer regardless of the number
of wasted bytes. In those cases src and dst of the memcpy() call may

234:    /* more than 50% of the buffer is available before the read pointer,    * and we can discard that data. Move the data to the beginning, making    * room for more data. -  * -  * NOTE: since the empty space at the beginning is bigger than half of the full -  * allocated space, src and dst do not overlap. We can therefore use memcpy(). +     */ -  memcpy( io->buffer, io_read_pointer(io), io_len(io) ); +  memmove( io->buffer, io_read_pointer(io), io_len(io) );    io->num_move++;    io->len -= io->offset;    io->offset = 0;