resource.c: bugfix: Memory leak from hash table

The function coap_delete_all_resources() did not free the hash buckets
created by HASH_ADD. Thus, the iterator must call HASH_DELETE to free
the allocated storage.

This bug has been discovered  by
Jean-Michel Julien <Jean-Michel.Julien@trilliantinc.com>
who also provided this fix. See [1] for more information.

[1] https://sourceforge.net/p/libcoap/mailman/message/34994226/
This commit is contained in:
Olaf Bergmann committed 2016-04-06 12:43:27 +02:00
1 parent 4a5f381978
commit 7dea55099f
1 file changed
+1
+1
View File
@@ -457,6 +457,7 @@ coap_delete_all_resources(coap_context_t *context) {
LL_FOREACH_SAFE(context->resources, res, rtmp) {
#else
HASH_ITER(hh, context->resources, res, rtmp) {
HASH_DELETE(hh, context->resources, res);
#endif
coap_free_resource(res);
}