- struct weston_seat *wseat = get_ivi_shell_weston_first_seat(surface->ivi);
- struct ivi_shell_seat *ivi_seat = get_ivi_shell_seat(wseat);
+ struct weston_seat *wseat = NULL;
+ struct ivi_shell_seat *ivi_seat = NULL;
+ struct ivi_output *output = NULL;
+
+ /* we might not have a valid ivi_surface if _added failed due to
+ * protocol errors */
+ if (!surface)
+ return;
+
+ wseat = get_ivi_shell_weston_first_seat(surface->ivi);
+ if (wseat)
+ ivi_seat = get_ivi_shell_seat(wseat);