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

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

9.3.4 ID_while_scope
目录 › next › previous

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

示例:

while (condition)
    statement1; statement2;  // Non-compliant

while (condition)
    statement1;
    statement2;  // Non-compliant

例中 statement2 不在 while 循环的作用域中,但看起来又和 while 循环相关,这种问题多数是由宏展开或无效的缩进造成的。

为了避免这种问题,while 语句应使用大括号括起来。

相关

ID_while_brace

参考

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