[devel] [PATCH for apt v2 06/21] Get rid of hardcoded array size

Aleksei Nikiforov darktemplar на altlinux.org
Чт Дек 12 12:57:15 MSK 2019


Found via cppcheck during investigation of previous issue.
---
 apt/apt-pkg/srcrecords.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apt/apt-pkg/srcrecords.cc b/apt/apt-pkg/srcrecords.cc
index 00e4f3c..35b89ee 100644
--- a/apt/apt-pkg/srcrecords.cc
+++ b/apt/apt-pkg/srcrecords.cc
@@ -145,7 +145,7 @@ const char *pkgSrcRecords::Parser::BuildDepType(unsigned char Type)
                            "Build-Depends-Indep",
 			   "Build-Conflicts",
 			   "Build-Conflicts-Indep"};
-   if (Type < 4) 
+   if (Type < sizeof(fields)/sizeof(*fields))
       return fields[Type]; 
    else 
       return "";
-- 
2.24.1



Подробная информация о списке рассылки Devel