From f81bf0fb4ef616bab6d58709cc65c2a6ede1add8 Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Thu, 24 Sep 2020 12:12:36 +0900 Subject: [PATCH] Fix the valgrind issue Invalid read of size 1 at 0x4B02F70: ____strtoul_l_internal (strtol_l.c:432) by 0x4B027F7: strtoul (strtol.c:106) by 0x489628F: ??? (in /usr/lib/libcapi-network-bluetooth.so.0.6.0) Change-Id: I074cacec908b65fd87e5376be16d96df528aa9f1 Signed-off-by: DoHyun Pyun --- src/bluetooth-adapter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bluetooth-adapter.c b/src/bluetooth-adapter.c index d4c22e6..16e3fb5 100644 --- a/src/bluetooth-adapter.c +++ b/src/bluetooth-adapter.c @@ -1969,8 +1969,8 @@ static int __bt_convert_string_to_uuid(const char *string, } /* ptr[4] contain "08x" and "04hx" */ - ptr[5] = g_malloc0(sizeof(char) * 8); - ptr[6] = g_malloc0(sizeof(char) * 4); + ptr[5] = g_malloc0(sizeof(char) * 8 + 1); + ptr[6] = g_malloc0(sizeof(char) * 4 + 1); strncpy(ptr[5], ptr[4], 8); strncpy(ptr[6], ptr[4] + 8, 4); -- 2.7.4