This is a big dilemma for you. When you talk about trying to make the decision of whether or not to stay married to your husband, I hear you talking about what the pros and cons are for your son and also what the pros and cons would be for your husband... what about for you? What are the pros and cons for you of staying with him? What about the pros and cons of filing for divorce? My guess is that being married to someone with a drug problem is very emotionally difficult for you in various ways- and that also, clearly, you love some things about him enough that you have stayed.
My point is that, if you can become clear about how best to take care of yourself and can act on that, this will be a very powerful role model for your son. That's not to say that staying or getting a divorce would then become easy, but it could help you to feel happier and stronger in yourself and your decision.
To answer your question more specifically, divorce is never easy or neat and is always painful for everyone involved (children included). Where your husband has a history of drug treatment the courts might limit his custody but chances are, if he's clean, there would be at least joint custody.
I'm glad you're seeking help online in making this decision. Would it maybe also be helpful to find a therapist who you could talk to face to face in a more ongoing kind of way? My thought is that, regardless of what you decide about staying with your husband, you could probably benefit from more support and a therapist could provide this for you.
It is not at all healthy for a child to live with an addicted parent. Even if the parent isn't violent, people with addictions are almost always unable to be consistent in their care giving and availability to their children. Children who grow up with an addicted parent are much more likely to be depressed and to marry someone with an addiction. They are also more likely to develop an addiction of their own.