mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-04-26 18:11:30 +02:00
Fix UB in v4raw_ref::operator==
Behaviour of memcmp is undefined if any of pointers passed to it is null. See https://en.cppreference.com/w/c/string/byte/memcmp for details. UB was detected on test MSGPACK_V4RAW_REF.pack_unpack_fix_l with UB-sanitizer.
This commit is contained in:
parent
dfbfd927b4
commit
90677eb58c
@ -33,7 +33,7 @@ struct v4raw_ref {
|
||||
|
||||
bool operator== (const v4raw_ref& x) const
|
||||
{
|
||||
return size == x.size && std::memcmp(ptr, x.ptr, size) == 0;
|
||||
return size == x.size && (size == 0 || std::memcmp(ptr, x.ptr, size) == 0);
|
||||
}
|
||||
|
||||
bool operator!= (const v4raw_ref& x) const
|
||||
|
Loading…
x
Reference in New Issue
Block a user