Depending on the configured segments it is possible to hit a
segmentation fault as a result of decrementing an unsigned index with
value 0.
To avoid it, exit the loop if the index has value 0.
Fixes: 40b966a211ab ("ivshmem: library changes for mmaping using ivshmem")
Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>