From 0b1bdbb339d3a764f464e0a972c396658114c24d Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 12 Apr 2017 15:25:08 +0200 Subject: [PATCH] TT#14400 Do not NULL-dereference pointer When debugging mode is enabled, and the socket variable is NULL, we will try to dereference it to print the debug message. Split the checks to avoid that. Change-Id: I0e0643900d3d8463937b7fd47b21cd91cf49b73c --- daemon/socket.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/daemon/socket.c b/daemon/socket.c index 9a1bc4f16..924f58095 100644 --- a/daemon/socket.c +++ b/daemon/socket.c @@ -633,7 +633,11 @@ int connect_socket_nb(socket_t *r, int type, const endpoint_t *ep) { } int close_socket(socket_t *r) { - if (!r || r->fd == -1) { + if (!r) { + __C_DBG("close() syscall not called, no socket"); + return -1; + } + if (r->fd == -1) { __C_DBG("close() syscall not called, fd=%d", r->fd); return -1; }