region: Fix crash in keyboard layout population

The previous code would crash if 'variants' was null and 'layouts' had
more than one element in it.
11 jobs for fix-keyboard-layout-crash in 4 minutes and 16 seconds (queued for 3 seconds)
Status Job ID Name Coverage
  Build
passed #430121
build

00:02:24

 
  Test
passed #430123
asan

00:01:51

passed #430122
test

00:01:19

 
  Manual
manual #430128
allowed to fail manual
armv8
manual #430124
allowed to fail manual
flatpak
manual #430127
allowed to fail manual
msan
manual #430129
allowed to fail manual
ppc64le
manual #430125
allowed to fail manual
tsan
manual #430126
allowed to fail manual
ubsan
 
  Review
manual #430130
allowed to fail manual
review
manual #430131
allowed to fail manual
stop_review