xcbgrab: Move NULL check before pointer dereference