1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 15:03:53 +01:00

net/gcoap: Avoid endless loop on error

The NULL case can not regularly be reached (because regularly
gcoap_register_listener sets thel link_encoder to a default one), but if
it is (eg. because an application unsets its link_encoder to hide a
resource set at runtime), the existing `continue` is a good idea (skip
over this entry) but erroneously created an endless loop by skipping the
advancement step.
This commit is contained in:
chrysn 2020-10-02 20:51:40 +02:00
parent 10592f2bb1
commit e3db58f013

View File

@ -887,7 +887,7 @@ int gcoap_get_resource_list(void *buf, size_t maxlen, uint8_t cf)
ctx.flags = COAP_LINK_FLAG_INIT_RESLIST;
/* write payload */
while (listener) {
for (; listener != NULL; listener = listener->next) {
if (!listener->link_encoder) {
continue;
}
@ -912,8 +912,6 @@ int gcoap_get_resource_list(void *buf, size_t maxlen, uint8_t cf)
break;
}
}
listener = listener->next;
}
return (int)pos;