but this whole theory about macs having no virus or security problems is not true as viruses or malichious software can be written for anything. its just a case of there not being as many for macs as they are not nearly as popular as windows.
A potential exploit and a virus that takes advantage of an exploit are two different things.
There are always holes in operating systems, as there will be in any software that is made by human beings.
A virus (or better said, a "worm") can be created to take advantage of an exploit. If the exploit is patched before a worm is created, there is no threat.
As yet, there have been plenty of exploits discovered, but there has never been an actual virus or worm that infiltrated the Mac outside of a lab environment.
By contrast, Windows has been attacked by active Malware consistently since its release. OS X has never had an active infection in the wild. Much of this is due to the fact that even if a worm were to penetrate via an open hole, the user typically doesn't have enough rights for it to be destructive in the first place. The end result is that worms haven't been written, because the potential for one is limited due to OS X's inherent security strengths.
So, while in effect, there is a potential for a virus on a Mac, there has not been one in the 7 years since OS X was released.