Torah Temimah cites Bava Kamma 91b.
One might think that if he swore to harm himself and did not, he would be exempt — Scripture says “to harm or to benefit”: just as benefit is optional, so harm is optional.
The parallel of optional benefit includes optional self-directed harm within the verse’s scope for the oleh ve-yored.
Category E — Analogy / comparison
Method — The Gemara compares optional benefit to optional self-directed harm: just as a person may choose whether to benefit himself, he may also choose whether to harm himself. This includes an oath about an optional act of self-harm within the scope of shevu’as bitui.
Textual trigger — “לְהָרַע אוֹ לְהֵיטִיב,” interpreted as “מַה הֲטָבָה רְשׁוּת אַף הֲרָעָה רְשׁוּת.”