The crash was caused when dereferencing nullptr in DumpObject and printArchiveChild.
In DumpObject, we have
2311 StringRef ArchiveName = a != nullptr ? a->getFileName() : ""; ... 2323 printArchiveChild(a->getFileName(), *c);
2368 StringRef ArchiveName = A ? A->getFileName() : ""; ... 2378 printArchiveChild(A->getFileName(), *C);
Look, this will cause segment fault when we use -a option on Non-archive files.
Besides, in printArchiveChild
2236 static void printArchiveChild(StringRef Filename, const Archive::Child &C) { 2237 Expected<sys::fs::perms> ModeOrErr = C.getAccessMode(); ...
This can also cause segment fault when calling C.getAccessMode() (&C can be nullptr).
I update the printArchiveChild argument by taking a pointer of Archive::Child and check whether it's a nullptr.
This is a draft, I will add some tests later.
Any suggestions are welcoming, thanks
It seems like you could just add && c here and in the second overload and the signature of printArchiveChild could stay the same.