From 693a4e2313860c7d038a96fb57730247717d1da8 Mon Sep 17 00:00:00 2001 From: kkrentz Date: Mon, 13 Dec 2021 13:07:48 +0100 Subject: [PATCH] net.c: correct return value in coap_send_internal() The interface description of coap_send_internal says that COAP_INVALID_MID is returned in the case of errors. Presently, it, however, returns "(coap_mid_t)bytes_written" in a special case. Accidentally, bytes_written == -1 == COAP_INVALID_MID in this specific case, which is why no problems occur in practice due to this. As a cosmetic fix, this commit changes the return value to COAP_INVALID_MID. --- src/net.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/net.c b/src/net.c index 576193c1..cf703628 100644 --- a/src/net.c +++ b/src/net.c @@ -1281,8 +1281,7 @@ coap_send_internal(coap_session_t *session, coap_pdu_t *pdu) { } if (bytes_written < 0) { - coap_delete_pdu(pdu); - return (coap_mid_t)bytes_written; + goto error; } #if !COAP_DISABLE_TCP