Crash probably introduced by 4d17a1b0. Inialize the window to NULL and verify it before use.
4d17a1b0