diff options
author | Jacques Lucke <jacques@blender.org> | 2021-11-02 17:07:35 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-11-02 17:07:50 +0300 |
commit | 698b05fc58f65ffe997fd18958c7d075277021d7 (patch) | |
tree | 1adbb660216a1dc0b3c82b44348f0a4457bd7bda /source/blender/blenlib/BLI_string_ref.hh | |
parent | efcf36f2e9773f30fa6d4cce8fd0e793b9694b78 (diff) |
BLI: avoid passing nullptr to strncmp
This resulted in an ASAN warning.
Diffstat (limited to 'source/blender/blenlib/BLI_string_ref.hh')
-rw-r--r-- | source/blender/blenlib/BLI_string_ref.hh | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_string_ref.hh b/source/blender/blenlib/BLI_string_ref.hh index 34baf94c448..dc73208350f 100644 --- a/source/blender/blenlib/BLI_string_ref.hh +++ b/source/blender/blenlib/BLI_string_ref.hh @@ -610,6 +610,10 @@ constexpr bool operator==(StringRef a, StringRef b) if (a.size() != b.size()) { return false; } + if (a.data() == b.data()) { + /* This also avoids passing null to the call below, which would results in an ASAN warning. */ + return true; + } return STREQLEN(a.data(), b.data(), (size_t)a.size()); } |