内存bug的检查列表

前些时候有个同事调试一个有关内存的bug,因此想了一下检查列表,总结如下:

1. Build project with /GS (to check the buffer when it is writen immediately)
2. Copy the pdb file with the binaries
3. Locate the files and lines dumped
4. For string error:
4.1. Check if buffer overflow
4.2. Check where the buffer is written
5. For pointer error:
5.1. Check if the pointer is successfully allocated
5.2. Check if the pointer is valid
5.3. Check if the pointer is initialized
5.4. Check how the pointer is set
6. For infinite loop
6.1. find the head of the loop
6.2. Check the condition for break the loop
6.3. Check where is the location for not meeting the condition
7. For array error
7.1. Check the length of the array
7.2. Check the border of the array

就想到这些了,以后有新的再添加。

你可能感兴趣的:(C/C++语言,buffer,border,string,build,file)