Diff between d20eb4abfed25a86dab93b35be02971e03d7555d and 027a4610a720be05e0fe0b9fd74ecceabf46c9d4

Changed Files

File Additions Deletions Status
profiles/gap/gas.c +12 -1 modified

Full Patch

diff --git a/profiles/gap/gas.c b/profiles/gap/gas.c
index 7d81592..762e352 100644
--- a/profiles/gap/gas.c
+++ b/profiles/gap/gas.c
@@ -101,7 +101,18 @@ static void read_device_name_cb(bool success, uint8_t att_ecode,
 					void *user_data)
 {
 	struct gas *gas = user_data;
-	char *name = name2utf8(value, length);
+	char *name;
+
+	if (!success) {
+		DBG("Reading device name failed with ATT errror: %u",
+								att_ecode);
+		return;
+	}
+
+	if (!length)
+		return;
+
+	name = name2utf8(value, length);
 
 	DBG("GAP Device Name: %s", name);