1. Memory leak: The requested heap memory is not disposed.
2. Memory pollution: in front of illegal operation using memory (no error), written in the back of the error. The following code:
When the structure is only underlined part of the code, written in the compiler will not error, but at this time has caused the illegal operation of memory, the following to add some variables to the structure, this will be an error, do not let the definition of variables (this error is particularly difficult to debug) need attention.
3. The determination of an empty string and an illegal string:
The part of the picture that draws the Blue line: The value of the pointer variable should be judged, not the memory that the pointer points to
4. Pointer out of bounds: such as: str[3] = "ABC";
5. The pointer overlay will constantly change the pointer's direction.
such as: char *p = "SDFG"; p++; printf ("%s\n", p); Print result: "DFG";. The pointer only wants to be changed, if it is superimposed 4 times, it will not print the content, because the pointer is now pointing to the Terminator.
6. The address of the local variable of the stack is not to be exported. Such as:
Char *get_str () {char str[] = "abcdedsgads";//Stack area, printf ("[GET_STR]STR =%s\n", str); return str;}
7. The same memory area is released multiple times;
Har *p = null;p = (char *) malloc (n), strcpy (p, "abcdef"), if (P! = NULL) {//free () function only tells the system p points to the memory can be recycled//That is, p points to the memory use Back to the system//However, the value of P is still the original value (wild pointer), p still points to the original memory free (p);} if (P! = NULL) {free (p);}
The easy-to-wrong point of C language pointers