The judge in the Charlie Sheen/Brooke Mueller custody war did not award Charlie full custody because of Charlie's checkered past.
Sources familiar with the case tell TMZ ... Judge Hank Goldberg was well aware Brooke had relapsed into drug use, but the judge was equally disturbed by Charlie's substance abuse and the fact that he bragged about it.
TMZ broke the story ... the judge denied Charlie's request to strip Brooke of custody and award him full legal and physical custody of twins Bob and Max. Judge Goldberg kept the status quo, ruling the custody agreement Charlie and Brooke struck last month will remain in effect.
Judge Goldberg also felt Charlie's parenting skills -- or lack thereof -- did not warrant a change. And, we're told, Brooke's lawyers raised issues of prior domestic violence on Charlie's part, though there were no fresh allegations.
In the end, sources say Judge Goldberg felt both Brooke and Charlie had problems, but the twins were adequately protected by the nannies, relatives and other support staff.
One final thing. We're told Judge Goldberg did not hold the fact that Charlie brought his goddess to court against him.