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

while 语句中不应存在无条件的跳转语句

9.3.2 ID_while_uncondBroken
目录 › next › previous

不受条件限制的 return、throw 或 break 语句会使循环失效,不受条件限制的 continue 语句会使其后面的代码失效,如果其后没有代码,该 continue 语句是没有意义的。

示例:

while (condition) {
    ....
    return;     // Non-compliant
}

while (condition) {
    ....
    break;      // Non-compliant, becomes an if-statement
}

while (condition) {
    ....
    continue;   // Non-compliant, meaningless continue
}

这种问题多数由错误的缩进或混乱的逻辑造成。

相关

ID_uncondJump ID_for_uncondBroken

参考

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