Skip to content

Commit 35820f2

Browse files
rlubosfabiobaltieri
authored andcommitted
net: lwm2m: Add missing NULL pointer check in shell
In case lwm2m_get_engine_obj_field() fails to find a corresponding object field when iterating resource instances, simply skip that resource instance when printing object instance contents. Signed-off-by: Robert Lubos <[email protected]>
1 parent 48de0fc commit 35820f2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

subsys/net/lib/lwm2m/lwm2m_shell.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,10 @@ static int print_object_instance(const struct shell *sh, struct lwm2m_engine_obj
735735
lwm2m_get_engine_obj_field(obj, re->res_id);
736736
char path[LWM2M_MAX_PATH_STR_SIZE];
737737

738+
if (field == NULL) {
739+
continue;
740+
}
741+
738742
if (re->multi_res_inst) {
739743
snprintf(path, sizeof(path), "%hu/%hu/%hu/%hu", obj->obj_id,
740744
oi->obj_inst_id, re->res_id, ri->res_inst_id);

0 commit comments

Comments
 (0)