diff --git a/src/device.c b/src/device.c
index ec97fc8..aca28af 100644
--- a/src/device.c
+++ b/src/device.c
}
uuid = bt_name2string(pattern);
+ if (uuid == NULL)
+ return btd_error_invalid_args_str(msg,
+ ERR_BREDR_CONN_INVALID_ARGUMENTS);
+
reply = connect_profiles(dev, BDADDR_BREDR, msg, uuid);
free(uuid);
diff --git a/src/profile.c b/src/profile.c
index 9fdfb7d..ad20436 100644
--- a/src/profile.c
+++ b/src/profile.c
dbus_message_iter_get_basic(value, &str);
free(ext->service);
ext->service = bt_name2string(str);
+ if (ext->service == NULL)
+ return -EINVAL;
}
return 0;