|
PC-lint/FlexeLint Output | Reference Manual Explanation | Home Page bug433.cpp
In writing this program which allocates an array of 10 integers the programmer made one fatal flaw. Can you find it?
bug433.cpp lint Output
--- Module: bug433.cpp
_
p = (Array10) malloc( sizeof(Array10) );
bug433.cpp(8) : Warning 433: Allocated area not large enough for pointer
bug433.cpp(8) : Info 826: Suspicious pointer-to-pointer conversion (area too small)
_
}
bug433.cpp(20) : Warning 529: Symbol 'a' (line 17) not subsequently referenced
Reference Manual Explanation
433 Allocated area not large enough for pointer -- An allocation was assigned
to a pointer whose reach extends beyond the area that was allocated. This
would usually happen only with library allocation routines such as malloc
and calloc. For example:
int *p = malloc(1);
This message is also provided for user-declared allocation functions.
For example, if a user's own allocation function is provided with the
following semantic:
-sem(ouralloc,@P==malloc(1n))
We would report the same message. Please note that it is necessary
to designate that the returned area is freshly allocated (ala malloc).
This message is always given in conjunction with the more general
Informational Message 826.
|
Previous Bug - Bug