lib: fixed bad mallocs in socket

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>