☰
  • 首页
  • 规则分类
  • 项目介绍
search
•••

for 语句作用域的范围不应有误

9.2.3 ID_for_scope
目录 › next › previous

for 语句作用域的范围不应有误。

示例:

for (....)
    statement1; statement2;  // Non-compliant

for (....)
    statement1;
    statement2;  // Non-compliant

例中 statement2 不在 for 循环的作用域中,但看起来又和 for 循环相关,这种问题多数是由宏展开或无效的缩进造成的。为了避免这种问题,for 语句应使用大括号括起来。

相关

ID_for_brace

参考

CWE-483
Copyright©2024 360 Security Technology Inc., Licensed under the Apache-2.0 license.