Fix segmentation fault when using ZapImage::PrintStats() (dotnet/coreclr#9731)
Currently, ZapImage::PrintStats is not used anywhere. But I want to get detailed informations about Native Image(ni.dll) components.
So I just used ZapImage::PrintStats when called ZapImage::SaveImage. After that I met the segmentation fault likes dotnet/coreclr#9680.
I found the reason for this issue is accessing the null pointer to get sizes.
Commit migrated from https://github.com/dotnet/coreclr/commit/
e876e8147d06a213f562021a4d02a5a60ba63c99