Bluetooth: Shell: BR: Add NULL pointer check for result->resp_buf

In case the peer device has NO SDP record, the result is valid,
but the result->resp_buf is NULL, it would introduce a hardfault.
Therefore, also add a NULL pointer check for result->resp_buf.

Signed-off-by: Make Shi <make.shi@nxp.com>
This commit is contained in:
Make Shi 2024-12-11 13:26:14 +08:00 committed by Benjamin Cabé
commit 345c3f17eb

View file

@ -380,7 +380,7 @@ static uint8_t sdp_hfp_ag_user(struct bt_conn *conn,
conn_addr_str(conn, addr, sizeof(addr));
if (result) {
if (result && result->resp_buf) {
shell_print(ctx_shell, "SDP HFPAG data@%p (len %u) hint %u from"
" remote %s", result->resp_buf,
result->resp_buf->len, result->next_record_hint,
@ -440,7 +440,7 @@ static uint8_t sdp_a2src_user(struct bt_conn *conn,
conn_addr_str(conn, addr, sizeof(addr));
if (result) {
if (result && result->resp_buf) {
shell_print(ctx_shell, "SDP A2SRC data@%p (len %u) hint %u from"
" remote %s", result->resp_buf,
result->resp_buf->len, result->next_record_hint,