Tor does a variety of things to make sure that the source code is safe. First of all Tor is Free Software. That means anyone can review the code and contribute to it. While anyone can contribute it doesn't mean that anyones contribution find their way into the code. All contributions are reviewed (link goes to all trac tickets which need review), the contributor gets feedback and only when the reviewer thinks it is worthwhile the code is added. Furthermore the Tor Project uses Coverity scan. This project scans the source code and warns if it finds bugs or mistakes in the source code.
If someone don't trust the binary there are deterministic builds. This way one can check out the code, build it for themselves and check if their build has the same hash value than the official Tor binary.
There are more things like software tests, university projects which also deal with the security of Tor's source code. So all in all Tor tries all possible to have a secure source code.