I eat lots of the stuff from my cafeteria at College. Frozen night after night because no-one takes them from the front window.
To my knowledge, there is no way of bacteria growing on chocolate or cake. As mentioned above.
Also, with most bacteria types, it has to be sitting in the warmth for bac to grow and multiply. Even so, boiling/burning/heating/whatever kills it, whilst freezing completely stops its reproduction cycle.
Foods like meat harbour it. Anthing from an animal. Because some can come from inside the body.
Cake is completely safe in my opinion.