New company, maintain an old code:
A memory out-of-bounds issue:
c = * (stext+nleng+1// Read whatever you * (stext+nleng+10// cross two characters, write bad memory
This will cause, under normal conditions without pressure to run without error, not core dump.
At the time of the high stress test (fork architecture), some processes will error malloc (): Memory corruption, and no core file generation.
This can only be done by commenting on the code.
And by the way, a memory leak problem was found:
Char *newchar[len+1// no delete behind
These styles are clearly the C + + code written by the developer.
Try using STL to manage allocation release issues.
1. Std::array<char, Num>, there is data () operation, but array is a template, num compiler resolution, I need to support runtime resolution.
2. Vector and string, this two all meet the requirements, vector changed memory, the inside of the count can not be added, it is not used, pollution code
The C_STR () string has to be const_cast, but there is no other choice.
String Management char Array, get rid of new delete