From: David Goulet Date: Thu, 25 Aug 2011 19:42:20 +0000 (-0400) Subject: Add NULL pointer check X-Git-Tag: v2.0-pre12~4 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=83009e5e25be5591c5a08e018e95a7d9baf7c108;ds=sidebyside Add NULL pointer check Signed-off-by: David Goulet --- 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;