Of course OSX has bugs. In fact, they've got some fairly nasty ones, given the relatively shoddy state of Apple's QA these days. It's still better than Microsoft's QA, but not by all that much.
What makes OSX better is not so much freedom from bugs as two other things. One, they have a response team which fixes security issues in a timely manner once reported; Microsoft does not. Two, the OS is just plain better designed, such that entire classes of security issues common on Windows simply cannot occur on Macs because the design doesn't allow them the opportunity to arise.