ble_mesh: Fix dereferencing pointer before checking for NULL [Zephyr]

The publication context is checked for NULL in bt_mesh_model_publish()
however it was dereferenced before that. Move the assignment to
ctx.send_rel to the same place where other ctx members are set.
This commit is contained in:
lly 2020-04-03 16:58:12 +08:00 committed by bot
parent b0a6fc7937
commit 367677c3bb

View file

@ -1032,9 +1032,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
struct bt_mesh_model_pub *pub = model->pub;
struct bt_mesh_app_key *key = NULL;
struct net_buf_simple *sdu = NULL;
struct bt_mesh_msg_ctx ctx = {
.send_rel = pub->send_rel,
};
struct bt_mesh_msg_ctx ctx = {0};
struct bt_mesh_net_tx tx = {
.sub = NULL,
.ctx = &ctx,
@ -1072,6 +1070,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
}
ctx.addr = pub->addr;
ctx.send_rel = pub->send_rel;
ctx.send_ttl = pub->ttl;
ctx.net_idx = key->net_idx;
ctx.app_idx = key->app_idx;