I think the problem you would have doing this is that when you pulled the pistol out of the case it would spit out of your hand like a watermelon seed.(I'm not a fan on storing firearms in oil, there are many other options already mentioned. I prefer the silicone socks. I buy the long rifle ones and then cut the size I need for pistols.)
point taken

I could use some silicone spray to waterproof the foam as a precaution so it doesn't trap or hold any moisture and use it in combination with the other things mentioned.