Checkers:UNINIT.STACK.ARRAY.MUST

From current

Reference > C/C++ checkers > UNINIT.STACK.ARRAY.MUST

This error indicates that the memory of a local array is read and there is a path in the program where the memory hasn't been initialized.

Contents

Vulnerability and risk

Uninitialized variables located in a stack may have garbage data in them. Usage of such variables will lead to unpredictable behavior.

Example 1

1  extern void ifoo(int);
2  
3  void uninit_array_must() {
4      int a[10];
5      ifoo(a[1]);
6  }

Klocwork produces an uninitialized local array reading report, indicating that the memory of uninitialized array 'a' is used at line 5.

Related checkers

External guidance