wayland: Check the returned display value for null
In reality, this condition will never occur, since the index is checked before calling the display retrieval function, but aggressive LTO with jump threading can generate a warning if this isn't explicitly checked.
(cherry picked from commit 91bb1bb6fd042677c2725a1c9e6e99cb71dda247)