sock: avoid NULL pointer deref in xsockaddr_ntop

If we get a NULL address, return NULL.

Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
1 files changed, 3 insertions(+), 0 deletions(-)

M sock.c
M sock.c +3 -0
@@ 158,6 158,9 @@ const char *xsockaddr_ntop(const struct 
 {
 	const union xsockaddr *u = (const union xsockaddr *) sa;
 
+	if (!u)
+		return NULL;
+
 	switch (u->sa.sa_family) {
 		case AF_INET:
 			return inet_ntop(AF_INET, &u->inet.sin_addr, str,