workaround for attempting to write beyond buffer size