diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2021-12-20 15:51:49 -0800 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2021-12-23 11:45:31 -0800 |
commit | 2be2b945e23ea9740aef79d1e719ce793413e129 (patch) | |
tree | 08c77aca2541c256f72b2e95f068e264de5c6615 /tools/mesh-gatt | |
parent | 4839b1135d68adca9d58a0226734cac4a9793071 (diff) | |
download | bluez-2be2b945e23ea9740aef79d1e719ce793413e129.tar.gz |
build: Fix build when sanitizer are enabled
This fixes various issues found when sanitizers are enabled.
Diffstat (limited to 'tools/mesh-gatt')
-rw-r--r-- | tools/mesh-gatt/util.c | 11 |
1 files changed, 8 insertions, 3 deletions
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]); |