Fix the valgrind issue 50/244750/1 accepted/tizen_6.0_unified_hotfix tizen_6.0_hotfix accepted/tizen/6.0/unified/20201030.122631 accepted/tizen/6.0/unified/hotfix/20201103.004928 accepted/tizen/6.0/unified/hotfix/20201103.052335 accepted/tizen/unified/20200928.004603 submit/tizen/20200924.060847 submit/tizen_6.0/20201029.205102 submit/tizen_6.0_hotfix/20201102.192502 submit/tizen_6.0_hotfix/20201103.114802 tizen_6.0.m2_release
authorDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 24 Sep 2020 03:12:36 +0000 (12:12 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 24 Sep 2020 03:12:36 +0000 (12:12 +0900)
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 <dh79.pyun@samsung.com>
src/bluetooth-adapter.c

index d4c22e6..16e3fb5 100644 (file)
@@ -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);