BLI_string_ref: avoid passing null to strncmp (quiet ASAN warning)
The existing logic to avoid passing null only worked when both strings were null.
This commit is contained in:
parent
bd9602036a
commit
9f283bee7e
Notes:
blender-bot
2023-02-14 12:01:57 +01:00
Referenced by commit d3e8d63a8c
, Fix error in StringRef equality
|
@ -608,9 +608,14 @@ constexpr bool operator==(StringRef a, StringRef b)
|
|||
return false;
|
||||
}
|
||||
if (a.data() == b.data()) {
|
||||
/* This also avoids passing null to the call below, which would results in an ASAN warning. */
|
||||
/* This also avoids passing null to the call below when both are null,
|
||||
* which would results in an ASAN warning. */
|
||||
return true;
|
||||
}
|
||||
if (!a.data() || !b.data()) {
|
||||
/* Account for a single value being null, resulting in an ASAN warning. */
|
||||
return false;
|
||||
}
|
||||
return STREQLEN(a.data(), b.data(), size_t(a.size()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue