surface: cannot set a palette to a non-indexed surface
This fixes a UBSAN warning later in this function where it calculates
(1 << SDL_BITSPERPIXEL(surface->format)). The bpp might be >= 32 and
out of range for a bit shift.
(cherry picked from commit d5af35e3fbb5bb6555ed00e69740d52af2a4e877)