Skip to content

Commit 33c0995

Browse files
de-nordiccarlescufi
authored andcommitted
mgmt/mcumgr/lib: Fix zcbor_map_decode bulk
Fixed problem with uninitialized conditional variable. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 40f7651 commit 33c0995

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

subsys/mgmt/mcumgr/lib/util/src/zcbor_bulk.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,23 @@ int zcbor_map_decode_bulk(zcbor_state_t *zsd, struct zcbor_map_decode_key_val *m
1313
size_t map_size, size_t *matched)
1414
{
1515
bool ok;
16-
bool dok; /* Key decode ok */
1716
struct zcbor_map_decode_key_val *dptr = map;
1817

1918
if (!zcbor_map_start_decode(zsd)) {
2019
return -EBADMSG;
2120
}
2221

2322
*matched = 0;
24-
dok = true;
23+
ok = true;
2524

2625
do {
2726
struct zcbor_string key;
2827
bool found = false;
2928
size_t map_count = 0;
3029

31-
dok = zcbor_tstr_decode(zsd, &key);
30+
ok = zcbor_tstr_decode(zsd, &key);
3231

33-
while (dok && map_count < map_size) {
32+
while (ok && map_count < map_size) {
3433
if (dptr >= (map + map_size)) {
3534
dptr = map;
3635
}
@@ -61,10 +60,10 @@ int zcbor_map_decode_bulk(zcbor_state_t *zsd, struct zcbor_map_decode_key_val *m
6160
++map_count;
6261
}
6362

64-
if (!found && dok) {
63+
if (!found && ok) {
6564
ok = zcbor_any_skip(zsd, NULL);
6665
}
67-
} while (ok && dok);
66+
} while (ok);
6867

6968
return zcbor_map_end_decode(zsd) ? 0 : -EBADMSG;
7069
}

0 commit comments

Comments
 (0)