[Bf-blender-cvs] [698b05fc58f] blender-v3.0-release: BLI: avoid passing nullptr to strncmp

Jacques Lucke noreply at git.blender.org
Tue Nov 2 15:08:04 CET 2021


Commit: 698b05fc58f65ffe997fd18958c7d075277021d7
Author: Jacques Lucke
Date:   Tue Nov 2 15:07:35 2021 +0100
Branches: blender-v3.0-release
https://developer.blender.org/rB698b05fc58f65ffe997fd18958c7d075277021d7

BLI: avoid passing nullptr to strncmp

This resulted in an ASAN warning.

===================================================================

M	source/blender/blenlib/BLI_string_ref.hh

===================================================================

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());
 }



More information about the Bf-blender-cvs mailing list