From: Jin-Seong Kim Date: Tue, 18 Jul 2017 05:32:00 +0000 (+0900) Subject: netutils/libcoap : patch to prevent memory leakage caused by observers X-Git-Tag: 1.1_Public_Release~318^2~51 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b557dc0bd7626d39c1588fb2ef2d1e3ac32faefa;p=rtos%2Ftinyara.git netutils/libcoap : patch to prevent memory leakage caused by observers This commit is patch to prevent memory leakage caused by observers - there is no routine to free observers for libcoap-server - remained observers in a resource can cause memory leakage Change-Id: Ib2aefc9cd5f9572f5170fc96f0f832e02692dfc9 Signed-off-by: Jin-Seong Kim --- diff --git a/apps/netutils/libcoap/net.c b/apps/netutils/libcoap/net.c index 876d57e..1bfc400 100644 --- a/apps/netutils/libcoap/net.c +++ b/apps/netutils/libcoap/net.c @@ -493,6 +493,16 @@ void coap_free_context(coap_context_t *context) #else HASH_ITER(hh, context->resources, res, rtmp) { #endif +/* To prevent memory leakage due to remained subscribers */ +#ifndef WITHOUT_OBSERVE + coap_subscription_t *s = NULL; + for (s = list_head(res->subscribers); s; s = list_item_next(s)) { + if (s) { + list_remove(res->subscribers, s); + coap_free(s); + } + } +#endif coap_delete_resource(context, res->key); } #endif /* WITH_POSIX || WITH_LWIP */