Fixed crash when reading invalid file