Checkers:UNINIT.HEAP.MIGHT
From current
Reference > C/C++ checkers > UNINIT.HEAP.MIGHT
This error indicates that heap memory may not have been initialized before it is used. This error is detected only if memory was allocated with malloc.
Example 1
1 struct s { 2 int i; 3 }; 4 5 int f(struct s **v, int t) { 6 *v = (struct s *)malloc(sizeof(struct s)); 7 if (t > 0) { 8 (*v)->i = t; 9 } 10 return (*v)->i; 11 }
Klocwork produces an uninitialized heap memory reading report, indicating that variable '(*v)->i', which gets its value from the memory allocated at line 5, might be used uninitialized at line 10.
Related checkers
- UNINIT.HEAP.MIGHT
- UNINIT.HEAP.MUST


