From 2be2b945e23ea9740aef79d1e719ce793413e129 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Mon, 20 Dec 2021 15:51:49 -0800 Subject: build: Fix build when sanitizer are enabled This fixes various issues found when sanitizers are enabled. --- tools/mesh-gatt/util.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'tools/mesh-gatt') diff --git a/tools/mesh-gatt/util.c b/tools/mesh-gatt/util.c index e845c4112..eb8b8eb29 100644 --- a/tools/mesh-gatt/util.c +++ b/tools/mesh-gatt/util.c @@ -41,9 +41,14 @@ void print_byte_array(const char *prefix, const void *ptr, int len) char *line, *bytes; int i; - line = g_malloc(strlen(prefix) + (16 * 3) + 2); - sprintf(line, "%s ", prefix); - bytes = line + strlen(prefix) + 1; + if (prefix) { + line = g_malloc(strlen(prefix) + (16 * 3) + 2); + sprintf(line, "%s ", prefix); + bytes = line + strlen(prefix) + 1; + } else { + line = g_malloc((16 * 3) + 2); + bytes = line + 1; + } for (i = 0; i < len; ++i) { sprintf(bytes, "%2.2x ", data[i]); -- cgit v1.2.1