laurencelundblade / QCBOR

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

Do not take pointer math with nullptr #168

Closed Mephistophiles closed 1 year ago

Mephistophiles commented 1 year ago

This change combines the code under one NULL check for UsefulOutBuf. This will allow not to do unnecessary work with nullptr arithmetic. Also, this change removes the check for non-zero size for memmove, because it can handle this situation

Found by PVS-Studio:

 warning: V1004 [CWE-119] The '((uint8_t *) pMe->UB.ptr)' pointer was used unsafely after it was verified against nullptr. Check lines: 261, 268.