No, this is a margin violation. The person sold stock he did not have, nor had arranged to borrow. Not only would a person in violation NOT be able to keep the gains, their account will be restricted.
A double penalty for making such a mistake. That is how it works in the real world.