If it involves, say, a high-ranking general giving loads of top-secret military information to the enemy, it's likely that not giving away such information is part of his job description, and that he is in breach of contract. Now, the law might not like punishing breach of contract with long-term imprisonment (or whatever the penalty for treason is), but you could probably work something out--e.g. if he breaks contract, then he retroactively loses all access privileges, and all those times he accessed top-secret data are now considered trespass.
(This seems in fact quite appropriate to me, because then the punishment is proportional to the extent to which the general misused the privileges given to him. If he was new to the job and they didn't show him much of anything, then they have little to complain about him breaking their trust; if he's spent ten years getting his fingers in all their data with their conditional permission, and now they realize they shouldn't have allowed him, then they have a lot to complain about.)
The case of shouting "fire" in a crowded theater can be handled similarly: Customers agree not to do that sort of thing as a condition of being allowed into the theater, and if they break that, then they are guilty of trespass. You might complain that the customers didn't agree to any such thing, and that implicit contracts are bad. Fine, then the theater can put up a sign that says "You are not allowed to falsely shout 'fire'". As a matter of fact, I have seen many fire alarms in large buildings with a sign that says something like "$NNN fine for spurious triggering of this alarm".
The point is, there is no need to count any of these situations as cases where freedom of speech breaks down. These things can be illegal without allowing any chinks into your free-speech armor; they can be punished, not because they're an illegal form of speech, but because of something else.