I store all my handguns in their cases and they have been fine.
Not unlikley. Let me ask you a question. How many of your pistols have a parkerized finish over aluminum alloy?
Different courses for different horses applies here I think.
Incidentally there are 2 different types of foam.
(the softer, cheaper more common type
) which is basically an absorbant sponge sucking in everything in the air including water, salt air & so on & storing it in thousands of little cells.
(a stiffer slicker more expensive type
) which has every individual bubble closed instead of open to its neighbors) this is much better as it cant absorb water or pretty much anything else in the volumes that open cell can.
Lots of info on the types here:
If you want to store a gun in a closed case I'd suggest you swap out any open cell for closed cell & use LOTS of oil or preservative of your choice.
You can buy closed cell foam in sheets from lots of places but probably the most common & easiest to find is the "Yoga Mats" or "Sleeping pads" sold at sports & outdoor retailers. It comes in several thicknesses & you can easily cut it with a razor blade to biuld up fitted moisture-resistant custom foam interiors.