fix segfault if flush is called before the first frame