MT#61856 control_ng: hardening for `bencode_pretty_print()`

The dict pretty printer advances from key to value
by `chld = chld->sibling` and then prints the `chld`.

If a malformed dict ever reaches this func
with an odd number of child nodes, this can dereference NULL.

Just add guard against NULL.

Change-Id: Ia24671a5eba06dda8c48515fd9dc45fe7a9ec371
mr26.1
Donat Zenichev 4 weeks ago
parent 822e5b7cc3
commit 227e0170ef

@ -629,6 +629,8 @@ static void bencode_pretty_print(bencode_item_t *el, GString *s) {
g_string_append(s, sep);
bencode_pretty_print(chld, s);
g_string_append(s, ": ");
if (!chld->sibling)
break;
chld = chld->sibling;
bencode_pretty_print(chld, s);
sep = ", ";

Loading…
Cancel
Save