laurencelundblade / QCBOR

Comprehensive, powerful, commercial-quality CBOR encoder/ decoder that is still suited for small devices.
Other
186 stars 47 forks source link

Correct support for adding empty text/byte strings #170

Closed laurencelundblade closed 1 year ago

laurencelundblade commented 1 year ago

CBOR allows empty text and byte strings and QBOR supports them with AddText() and AddBytes() with a size of zero.

This however resulted in a call to memmove with a NULL pointer if the zero length string also (logically) had a null pointer (e.g., was NULLUsefulBufC). Calling memmove with a NULL pointer is not recommended and some static analyzers will correctly complain.

This PR also documents the support in UsefulBuf and adds tests.

This addresses #164