(iOS)UIKit_GetSupportedOrientations maybe receive invalid window

Used SDL: SDL 2.0.4(2015.7.7)

Used iOS: iOS 8.4.0

When user rotate device, code is into
supportedInterfaceOrientations will call UIKit_GetSupportedOrientations, and
sends window to its’ parameter.

But I found, window maybe invalid random. Once invalid, below statement in
UIKit_GetSupportedOrientations will result to application crash.

SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;

How to solve it?