Skip to content

Commit e4416ac

Browse files
committed
mesh: fix possible NULL dereference in bt_test_print_credentials
1 parent 69611f7 commit e4416ac

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

nimble/host/mesh/src/testing.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,14 @@ void bt_test_print_credentials(void)
170170

171171
console_printf("Friend cred: %d\n", i);
172172
console_printf("\tNetKeyIdx: %04x\n",
173-
sub[i].net_idx);
174-
console_printf("\tNID: %02x\n", subnet->keys->msg.nid);
175-
console_printf("\tEncKey: %s\n",
176-
bt_hex(subnet->keys->msg.enc, 16));
177-
console_printf("\tPrivKey: %s\n",
178-
bt_hex(subnet->keys->msg.privacy, 16));
173+
sub[i].net_idx);
174+
if (subnet) {
175+
console_printf("\tNID: %02x\n", subnet->keys->msg.nid);
176+
console_printf("\tEncKey: %s\n",
177+
bt_hex(subnet->keys->msg.enc, 16));
178+
console_printf("\tPrivKey: %s\n",
179+
bt_hex(subnet->keys->msg.privacy, 16));
180+
}
179181
}
180182
}
181183

0 commit comments

Comments
 (0)