From 74603f5ed3bb99d699b0c5cf091d870f22ea255b Mon Sep 17 00:00:00 2001 From: Andreas Schuh Date: Tue, 11 Jul 2017 09:45:17 +0100 Subject: [PATCH] fix: Static code analyzer error regarding strncmp with empty kRootDir string --- src/gflags.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gflags.cc b/src/gflags.cc index 08e4f45..f270798 100644 --- a/src/gflags.cc +++ b/src/gflags.cc @@ -591,7 +591,7 @@ const char* CommandLineFlag::CleanFileName() const { const char* clean_name = filename() + strlen(filename()) - 1; while ( clean_name > filename() ) { if (*clean_name == PATH_SEPARATOR) { - if (strncmp(clean_name, kRootDir, sizeof(kRootDir)-1) == 0) { + if (sizeof(kRootDir) > 1 && strncmp(clean_name, kRootDir, sizeof(kRootDir)-1) == 0) { clean_name += sizeof(kRootDir)-1; // past root-dir break; }