fixed bug #3524612 (Double free error when coap_send returns COAP_INVALID_TID)

From jsucaet's error description (Credits to Marc Haesen for revealing this bug):
The intent of the current code of coap_send is to release the allocated
memory upon success and not to release when an error has occured. However
this is broken (returning from coap_send with an error and a deallocated
pdu ptr is possible).
In the patch, I propose to let the calling function (of coap_send) be
responsible for free'ing the allocated pointer.
This commit is contained in:
Olaf Bergmann committed 2012-05-29 19:41:22 +02:00
1 parent 3d71f4ee64
commit 28a6d45cde
9 files changed
+53 -51

No files matched your search

+1 -1
View File
@@ -234,8 +234,8 @@ check_async(coap_context_t *ctx, coap_tick_t now) {
if (coap_send(ctx, &async->peer, response) == COAP_INVALID_TID) {
debug("check_async: cannot send response for message %d\n",
response->hdr->id);
coap_delete_pdu(response);
}
coap_delete_pdu(response);
coap_remove_async(ctx, async->id, &tmp);
coap_free_async(async);