```cpp template<typename T> inline void Serializer::output_type(T& t) { int len = sizeof(T); char* d = new char[len]; if (!m_iodevice.is_eof()){ memcpy(d, m_iodevice.current(), len); m_iodevice.offset(len); byte_orser(d, len); t = *reinterpret_cast<T*>(&d[0]); } delete [] d; } ``` 1. ```if (!m_iodevice.is_eof()){ ``` 这里有越界风险,current 没有越界,但 current + size 不保证不会越界; 2. ```char *d = new char[len];``` 有内存泄漏的情况,没有 delete 的时机 3. 有太多次的 memcpy 了,从socket 到 vector,再到这里的 d buffer,然后 copy 到变量 T
Activity
madadaaa commentedon May 13, 2020
好,我试试看