[bugfix] Access x[0] only if x has at least one entry

(cherry picked from commit 7faf61fe5b6add56d1ed252befd8b941a8a18eb1)
Signed-off-by: Christoph Grüninger <gruenich@dune-project.org>