From 83009e5e25be5591c5a08e018e95a7d9baf7c108 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Thu, 25 Aug 2011 15:42:20 -0400 Subject: [PATCH] Add NULL pointer check Signed-off-by: David Goulet --- liblttngctl/lttngctl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/liblttngctl/lttngctl.c b/liblttngctl/lttngctl.c index b83d5ca92..b64ace2e6 100644 --- a/liblttngctl/lttngctl.c +++ b/liblttngctl/lttngctl.c @@ -343,6 +343,16 @@ static int ask_sessiond(struct lttcomm_session_msg *lsm, void **buf) goto end; } + /* + * Extra protection not to dereference a NULL pointer. If buf is NULL at + * this point, an error is returned and data is freed. + */ + if (buf == NULL) { + ret = -1; + free(data); + goto end; + } + *buf = data; ret = size; -- 2.34.1