diff --git a/examples/coap-server.c b/examples/coap-server.c index 97f642da..0d428d03 100644 --- a/examples/coap-server.c +++ b/examples/coap-server.c @@ -1146,6 +1146,7 @@ hnd_proxy_uri(coap_context_t *ctx COAP_UNUSED, if (token && !coap_add_token(pdu, token->length, token->s)) { coap_log(LOG_DEBUG, "cannot add token to proxy request\n"); response->code = COAP_RESPONSE_CODE_INTERNAL_ERROR; + coap_delete_pdu(pdu); goto cleanup; } diff --git a/src/block.c b/src/block.c index 0482d530..eaea39bd 100644 --- a/src/block.c +++ b/src/block.c @@ -300,9 +300,9 @@ coap_cancel_observe(coap_session_t *session, coap_binary_t *token, LL_FOREACH(session->lg_crcv, cq) { if (cq->observe_set) { - if ((!token && !cq->app_token->length) || + if ((!token && !cq->app_token->length) || (token && full_match(token->s, token->length, cq->app_token->s, - cq->app_token->length)) { + cq->app_token->length))) { uint8_t buf[4]; coap_tid_t mid; coap_pdu_t * pdu = coap_pdu_duplicate(&cq->pdu, diff --git a/src/coap_cache.c b/src/coap_cache.c index b85da9df..a95b79cc 100644 --- a/src/coap_cache.c +++ b/src/coap_cache.c @@ -140,7 +140,11 @@ coap_new_cache_entry(coap_session_t *session, const coap_pdu_t *pdu, if (record_pdu == COAP_CACHE_RECORD_PDU) { entry->pdu = coap_pdu_init(pdu->type, pdu->code, pdu->tid, pdu->alloc_size); if (entry->pdu) { - coap_pdu_resize(entry->pdu, pdu->alloc_size); + if (!coap_pdu_resize(entry->pdu, pdu->alloc_size)) { + coap_delete_pdu(entry->pdu); + coap_free_type(COAP_CACHE_ENTRY, entry); + return NULL; + } /* Need to get the appropriate data across */ memcpy(entry->pdu, pdu, offsetof(coap_pdu_t, token)); memcpy(entry->pdu->token, pdu->token, pdu->used_size); diff --git a/src/coap_debug.c b/src/coap_debug.c index 13a21c21..4fd5340a 100644 --- a/src/coap_debug.c +++ b/src/coap_debug.c @@ -526,6 +526,7 @@ coap_show_pdu(coap_log_t level, const coap_pdu_t *pdu) { outbuflen = strlen(outbuf); snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, " ["); while ((option = coap_option_next(&opt_iter))) { + buf[0] = '\000'; if (!have_options) { have_options = 1; } else {