Some more information: that code was committed almost two years ago (28 October 2006):
Maybe at that time Psi was the only or one of the few implementations of SOCKS5. I tried looking at Psi's bugtracker and SVN log, but I couldn't find any worth mention to such a bug, or any bug report.
A) The bug is already fixed in Psi, but I couldn't get any proof
B) The bug is still there in Psi. In that case, it would be good to report it to them, and mention it in the ejabberd Release Notes.
In any case, ejabberd should be standard compliant. If that patch works correctly, it should be included in the incoming ejabberd 2.0.2.