socket: fix segfault