It is not inherently unsafe, but it may not be something you want to do for other reasons.
The main reasons not to store food in cast iron are:
- Foods, especially acidic foods, may continue to react with the iron, developing off flavors
- Moisture encourages cast iron to rust
- It is not good for maintenance of your pans seasoning, which is part of what makes cast iron pans so desirable for cooking
- Many cast iron skillets don't have a lid, which may be desirable to protect the food from drying out, getting odors and off flavors from other items in the refrigerator, or contributing odors to the other items in the refrigerator. This one, of course, applies to any pan.
Note: we have had extensive discussions elsewhere (see for example, this question, and the many links within). Putting the food hot into your refrigerator may not be the best practice (it is more ideal to cool it quickly, in a shallow dish in an ice water bath), but putting it into the refrigerator still somewhat hot is certainly better than simply leaving it out on the counter until it is cooler then putting it into the refrigerator.
Per the USDA (thanks to Athanasius for the link to the source material):
Hot food can be placed directly in the refrigerator or it can be
rapidly chilled in an ice or cold water bath before refrigerating.
Cover foods to retain moisture and prevent them from picking up odors
from other foods.
A large pot of food like soup or stew should be
divided into small portions and put in shallow containers before being
refrigerated. A large cut of meat or whole poultry should be divided
into smaller pieces or placed in shallow containers before