Checking we don't overwrite/overread the buffer