Avoid pass NULL to memcmp() (#3844)

If we exec "StringVal(len=0, ptr="") == StringVal(len=0,ptr=NULL)", it will pass NULL ptr to memcmp(). It should be avoided.
This commit is contained in:
HuangWei
2020-06-13 12:43:41 +08:00
committed by GitHub
parent dac156b6b1
commit 83d39ff9c9

View File

@ -644,7 +644,7 @@ struct StringVal : public AnyVal {
return false;
}
return ptr == other.ptr || memcmp(ptr, other.ptr, len) == 0;
return len == 0 || ptr == other.ptr || memcmp(ptr, other.ptr, len) == 0;
}
bool operator!=(const StringVal& other) const {