From 6c15afbbaed9be8864e24d04e646c2acc4de220e Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 4 Dec 2007 10:17:02 +0100 Subject: [PATCH] fix memory allocation when DISPLAY is not set --- awesome-client-common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/awesome-client-common.c b/awesome-client-common.c index 7c843746d..58ef8d7af 100644 --- a/awesome-client-common.c +++ b/awesome-client-common.c @@ -41,7 +41,8 @@ get_client_addr(const char *display) * + 3 for /, \0 and possibly 0 if display is NULL */ if(display && (tmp = strrchr(display, '.'))) *tmp = '\0'; - path_len = a_strlen(homedir) + a_strlen(CONTROL_UNIX_SOCKET_PATH) + (a_strlen(display) - 1) + 3; + path_len = a_strlen(homedir) + a_strlen(CONTROL_UNIX_SOCKET_PATH) + + (display ? (a_strlen(display) - 1) : 1) + 3; if(path_len >= ssizeof(addr->sun_path)) { fprintf(stderr, "error: path of control UNIX domain socket is too long");