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

指针指向长度为 0 的内存空间并被解引用

C++-Undefined-Behavior-14
目录 › next › previous

示例:

void foo(size_t n) {
    int* p = new int[n];
    p[0] = 123;            // Undefined behavior if ‘n’ is zero
    ....
    delete[] p;
}

如果例中参数 n 为 0,对 p 的解引用会导致未定义的行为。

依据

ISO/IEC 14882:2003 3.7.3.1(2)-undefined ISO/IEC 14882:2011 3.7.4.1(2)-undefined

规则

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