Fix crash with invalid files in sessions and invalid xml

Change-Id: I59b5b31def73578ad2bda413c416d8eb9413fce0