Fix issues for clang-analyzer-8
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_bar.cpp
index eca6efd29573a2d11a7bc4378f1e3d9519c96de8..16d70d70c5176c85244f731fbe5d1ccfca1990e8 100644 (file)
@@ -265,11 +265,19 @@ static gmx_bool lambda_components_check(const lambda_components_t *lc,
     {
         return FALSE;
     }
+    GMX_RELEASE_ASSERT((name != nullptr) || (name_length == 0),
+                       "If name is empty, the length of the substring to examine within it must be zero");
     len = std::strlen(lc->names[index]);
     if (len != name_length)
     {
         return FALSE;
     }
+    if (name_length == 0)
+    {
+        // Everything matches a zero-length substring. This branch is
+        // needed because name could in principle be nullptr.
+        return TRUE;
+    }
     return std::strncmp(lc->names[index], name, name_length) == 0;
 }