All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
Such a vow is not considered valid and binding, and it is impermissible for you to deliver on it. This is because you vowed to do something that is impermissible according to the Sharee'ah, i.e. abstinence from eating and drinking. This constitutes self-torture, which displeases Allaah, the Exalted. Moreover, even if the person means to seek closeness to Allaah Almighty by observing wisal in fasting (i.e. fasting continuously), such a fast is disliked in Islam. When a person takes a vow to do a disliked act, it is not incumbent on him to fulfill it. Moreover, we would like to highlight that masturbating is forbidden and that you should give it up whether or not you made a vow to do so.
Allaah Knows best.