Masturbation does neither of these two things, as it is completely self-centered. Therefore, it is immoral.
What human act
isn't self-centered? Anything you do, you do because you think it will make you feel good, or at least will make you feel better than the alternatives you have. Even the most altruistic acts are done because kind acts to others makes the doer feel good. Given that masturbation hurts no one and has been medically shown to have numerous benefits (such as stress relief, decreased risk of prostate cancer, etc.), it seems to me that there are a rather lot of worse things that one could do.