lobaro / lobaro-coap

CoAP Implementation in C
MIT License
124 stars 47 forks source link

Should we call coap_mem_release() on pMsg if PayloadMaxSize is exceeded? #39

Closed ChrisDinhNZ closed 2 years ago

ChrisDinhNZ commented 5 years ago

Hi there, When we call CoAP_CreateMessage(), we allocate some buffer for the message. After successfully allocating the buffer we check PayloadMaxSize and return null if exceeded. Should we free the buffer prior to returning or are we relying on the caller to clean up the buffer?

https://github.com/lobaro/lobaro-coap/blob/7f5fed4abf481cf7bef7e143fe4c8d2aee41abe8/src/coap_message.c#L165

niondir commented 5 years ago

I guess a free is missing there, the caller has no reference to the allocated memory as far as I see.

PR is welcome.