When the TF2 code was leaked, it resulted in new vectors of attack on the servers being found and the development of bots that are still ruining the game.
Imagine if you could simply deploy an army of fuzzers on a piece of code, vs what could be derived from client side probing. Yes, having access to the source is a problem.
Which wouldn't have been an issue for too long if Valve was still maintaining TF2. For a game still being maintained and developed like LoL, a new vector of attack would probably only last for a few days before it is patched or mitigated.
It's a bit different because TF2 is basically abandonware.